Skip to content

Checkpoint#1 repeat #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
1 change: 1 addition & 0 deletions Checkpoint#1-repeat
Submodule Checkpoint#1-repeat added at 0fde8e
34 changes: 34 additions & 0 deletions Checkpoint1FromPullRequest/BellaSalon.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2041
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BellaSalon", "BellaSalon\BellaSalon.csproj", "{243C5EAF-B5B8-4281-84A2-7944CC5828C8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BellaTests", "BellaTest\BellaTests.csproj", "{395E0E9A-00AC-4298-9F26-0F85C583ACB5}"
ProjectSection(ProjectDependencies) = postProject
{243C5EAF-B5B8-4281-84A2-7944CC5828C8} = {243C5EAF-B5B8-4281-84A2-7944CC5828C8}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{243C5EAF-B5B8-4281-84A2-7944CC5828C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{243C5EAF-B5B8-4281-84A2-7944CC5828C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{243C5EAF-B5B8-4281-84A2-7944CC5828C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{243C5EAF-B5B8-4281-84A2-7944CC5828C8}.Release|Any CPU.Build.0 = Release|Any CPU
{395E0E9A-00AC-4298-9F26-0F85C583ACB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{395E0E9A-00AC-4298-9F26-0F85C583ACB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{395E0E9A-00AC-4298-9F26-0F85C583ACB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{395E0E9A-00AC-4298-9F26-0F85C583ACB5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7218F4B5-D7CF-41B7-9DDA-C41C79CE11C7}
EndGlobalSection
EndGlobal
12 changes: 12 additions & 0 deletions Checkpoint1FromPullRequest/BellaSalon/BellaSalon.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" />
</ItemGroup>

</Project>
188 changes: 188 additions & 0 deletions Checkpoint1FromPullRequest/BellaSalon/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
//Don't know how to change directory of my ALREADY submitted Checkpoint#1,
//so I make a new branch and also making some changes in this project by typing
// these comments, so I can "git add" it to a new branch.
//
//*********************************************************************
//And I'm not being late.
//
//*********************************************************************

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using BellaSalon.Models;

namespace BellaSalon.Controllers
{
public class HomeController : Controller
{
public IActionResult CustomerIndex()
{
return View(Repository.Customers);
}
[HttpGet]
public IActionResult CustomerCreate()
{
return View();
}
[HttpPost]
public IActionResult CustomerCreate(Customer customer)
{
if (!ModelState.IsValid)
{
return View();
}
Repository.CustomerAdd(customer);
return View("CustomerIndex", Repository.Customers);
}
public IActionResult CustomerDelete(Guid ID)
{
var DelCustomer = Repository.Customers.ToList().Find(c => c.ID == ID);
Repository.CustomerRemove(DelCustomer);
return View("CustomerIndex", Repository.Customers);
}
public IActionResult ServiceProviderIndex()
{
return View(Repository.ServiceProviders);
}
[HttpGet]
public IActionResult ServiceProviderCreate()
{
return View();
}
[HttpPost]
public IActionResult ServiceProviderCreate(ServiceProvider serviceProvider)
{
if (!ModelState.IsValid)
{
return View();
}
Repository.ServiceProviderAdd(serviceProvider);
return View("ServiceProviderIndex", Repository.ServiceProviders);
}
public IActionResult ServiceProviderDelete(Guid ID)
{
var DelServiceProvider = Repository.ServiceProviders.ToList().Find(s => s.ID == ID);
Repository.ServiceProviderRemove(DelServiceProvider);
return View("ServiceProviderIndex", Repository.ServiceProviders);
}
public IActionResult AppointmentsByDate(string name)
{
var SPAppointments = Repository.Appointments.Where(a => a.ServiceProvider == name).ToList();

ViewBag.SPAppointments = SPAppointments.OrderBy(a => a.Date).ThenBy(a => a.Time).ToList();
ViewBag.ServiceProvider = name;
ViewBag.Customers = Repository.Customers.ToList();
return View();
}
public IActionResult AppointmentIndex()
{
return View(Repository.Appointments);
}
[HttpGet]
public IActionResult AppointmentCreate()
{
return View();
}
[HttpPost]
public IActionResult AppointmentCreate(Appointment appointment)
{
bool custExists = false;
bool serviceProviderExists = false;
bool doubleBooked = false;
foreach (var c in Repository.Customers)
{
if (appointment.Customer == c.Name)
custExists = true;
}
foreach (var s in Repository.ServiceProviders)
{
if (appointment.ServiceProvider == s.Name)
serviceProviderExists = true;
}
foreach (var a in Repository.Appointments)
{
if (appointment.Date == a.Date && appointment.Time == a.Time && (appointment.Customer == a.Customer || appointment.ServiceProvider == a.ServiceProvider))
{
doubleBooked = true;
}
}
if (custExists && serviceProviderExists && !doubleBooked)
{
Repository.AddAppointment(appointment);
}
else
{
ViewBag.error = "Invalid Appointment";
}
return View("AppointmentIndex", Repository.Appointments.OrderBy(a => a.Date).ThenBy(a => a.Time));
}

public IActionResult AppointmentDelete(Guid ID)
{
var DelAppointment = Repository.Appointments.ToList().Find(a => a.ID == ID);
Repository.AppointmentRemove(DelAppointment);
return View("AppointmentIndex", Repository.Appointments);
}

public IActionResult Index()
{
ViewData["message"] = "Bella's Spa and Nails";
return View("BellaSalon");
}

public IActionResult Home()
{
return View("Home");
}
//public IActionResult Contact()
//{
// ViewData["Message"] = "Your contact page.";

// return View();
//}

//[HttpGet]
//public ViewResult FindAppointment()
//{
// ViewData["Message"] = "Enter Customer's Information to find booked appointment";

// return View();
//}
//[HttpPost]
//public ViewResult FindAppointment(AppointmentResponse appointmentResponse)
//{
// if (ModelState.IsValid)
// {
// Repository.AddResponse(appointmentResponse);
// return View("Thanks", appointmentResponse);
// }
// else
// {
// //there is a validation error
// return View();
// }
//}

//public ViewResult AppointmentDetailReport()
//{
// return View(Repository.Responses);
//}

//public IActionResult Privacy()
//{
// return View();
//}

//[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
//public IActionResult Error()
//{
// return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
//}

}
}

35 changes: 35 additions & 0 deletions Checkpoint1FromPullRequest/BellaSalon/Models/Appointment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace BellaSalon.Models
{
public class Appointment
{
public Appointment()
{
ID = Guid.NewGuid();
}
public Guid ID { get; set; }

[Required(ErrorMessage = "Please enter Full name")]
[RegularExpression(@"^[a-zA-Z ]+$",
ErrorMessage = "For a name, use letters only please")]
public string Customer { get; set; }

public string Date { get; set; }

[Required(ErrorMessage = "Please enter valid Time")]
[RegularExpression(@"\d{2,2}/\d{2,2}/\d{4,4} \d{2,2}:\d{2,2}:\d{2,2}",
ErrorMessage = "Invalid Time")]
public string Time { get; set; }

[Required(ErrorMessage = "Please enter Service Provider")]
[RegularExpression(@"^[a-zA-Z ]+$",
ErrorMessage = "For your Service Provider, use letters only please")]
public string ServiceProvider { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;

namespace BellaSalon.Models
{
public class AppointmentResponse
{
[Required(ErrorMessage = "Please enter Full name")]
[RegularExpression(@"^[a-zA-Z ]+$",
ErrorMessage = "For a name, use letters only please")]
public string Name { get; set; }

[Required(ErrorMessage = "Please enter customer's phone number")]
[RegularExpression(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$",
ErrorMessage = "Invalid Phone number")]
public string Phone { get; set; }

[Required(ErrorMessage = "Please enter Customer's Email")]
public string Email { get; set; }

[Required(ErrorMessage = "Please enter Service Provider")]
[RegularExpression(@"^[a-zA-Z]+$",
ErrorMessage = "For your Service Provider, use letters only please")]
public string ServiceProvider { get; set; }

public string Appointment { get; set; }
}
}
Loading