Begun integration of models and managers
The HotelManager class now has been connected to some aspects of the command line interface and is functioning for a few cases such as logging in as a specific guest via email, chaging a guests information and creating a new guest account. This was implemented first over the reservation system to test and implement something on a smaller scale. Furthermore, the reservation depends on an existing guest account since a Guest ID needs to be linked to the reservation that is created. Other changes include redesigning, tweaking/ adjusting, and/ or fixing of other modules that have not yet been implemented or are partially implemented.
This commit is contained in:
@@ -9,72 +9,14 @@ class Program
|
||||
{
|
||||
Reservation? activeReservation = null;
|
||||
Guest? activeGuest = null;
|
||||
|
||||
void help()
|
||||
{
|
||||
Console.WriteLine(
|
||||
"Reservation Commands:\n" +
|
||||
"\treservation create\n" +
|
||||
"\treservation update\n" +
|
||||
"\treservation cancel\n" +
|
||||
"Account Commands:\n" +
|
||||
"\taccount create\n" +
|
||||
"\taccount update\n" +
|
||||
"Enter Q to quit.\n"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateNewReservation()
|
||||
{
|
||||
Reservation newReservation;
|
||||
}
|
||||
|
||||
void CreateNewGuestPrompt()
|
||||
{
|
||||
(string?, string?, string?) GetCreditCardInformation()
|
||||
{
|
||||
Console.Write("What is your credit card number: ");
|
||||
string CreditCard = "";
|
||||
while (!Validation.ValidateCreditCard(CreditCard))
|
||||
{
|
||||
CreditCard = Console.ReadLine().Trim().Replace("\t", "");
|
||||
if (CreditCard == "q" || CreditCard == "Q")
|
||||
return (null, null, null);
|
||||
if (!Validation.ValidateCreditCard(CreditCard))
|
||||
Console.Write("Please enter a valid credit card. If your card is expired, enter Q to cancel: ");
|
||||
}
|
||||
Console.Write("What is your credit card expiration date (MM/yy): ");
|
||||
string CardExpiration = "";
|
||||
while (!Validation.ValidateExpirationDate(CardExpiration))
|
||||
{
|
||||
CardExpiration = Console.ReadLine().Trim().Replace("\t", "");
|
||||
if (CardExpiration == "q" || CardExpiration == "Q")
|
||||
return (null, null, null);
|
||||
if (!Validation.ValidateExpirationDate(CardExpiration))
|
||||
Console.Write("Please enter a valid expiration date. If your card is expired, enter Q to cancel: ");
|
||||
}
|
||||
Console.Write("What is your credit card CCV: ");
|
||||
string CCV = "";
|
||||
while (!Validation.ValidateCCV(CCV))
|
||||
{
|
||||
CCV = Console.ReadLine().Trim().Replace("\t", "");
|
||||
if (CCV == "q" || CCV == "Q")
|
||||
return (null, null, null);
|
||||
if (!Validation.ValidateCCV(CCV))
|
||||
Console.Write("Please enter a valid credit card CCV. If your card is expired, enter Q to cancel: ");
|
||||
}
|
||||
return (CreditCard, CardExpiration, CCV);
|
||||
}
|
||||
(string, string) GetGuestName() {
|
||||
Console.Write("What is your first name: ");
|
||||
string FirstName = "";
|
||||
while (FirstName.Length == 0)
|
||||
{
|
||||
FirstName = Console.ReadLine();
|
||||
if (FirstName == "")
|
||||
Console.Write("What is your first name: ");
|
||||
string FirstName = "";
|
||||
while (FirstName.Length == 0)
|
||||
{
|
||||
FirstName = Console.ReadLine();
|
||||
if (FirstName == "")
|
||||
Console.Write("What is your first name: ");
|
||||
}
|
||||
Console.Write("What is your last name: ");
|
||||
string LastName = "";
|
||||
@@ -84,7 +26,38 @@ class Program
|
||||
if (LastName == "")
|
||||
Console.Write("What is your last name: ");
|
||||
}
|
||||
return (FirstName, LastName);
|
||||
}
|
||||
string GetGuestEmail()
|
||||
{
|
||||
Console.Write("What is your email: ");
|
||||
string Email = "";
|
||||
while (!Validation.ValidateEmail(Email))
|
||||
{
|
||||
Email = Console.ReadLine();
|
||||
if (!Validation.ValidateEmail(Email))
|
||||
Console.Write("Please enter a valid email: ");
|
||||
}
|
||||
return Email;
|
||||
}
|
||||
void help()
|
||||
{
|
||||
Console.WriteLine(
|
||||
"Reservation Commands:\n" +
|
||||
"\treservation create - Create a new reservation.\n" +
|
||||
"\treservation update - Update your active reservation.\n" +
|
||||
"\treservation cancel - Cancel a reservation.\n" +
|
||||
"Account Commands:\n" +
|
||||
"\taccount create - Create a new guest account.\n" +
|
||||
"\taccount update - Update your account information.\n" +
|
||||
"\taccount login - Log into your guest account." +
|
||||
"Enter Q to quit.\n"
|
||||
);
|
||||
return;
|
||||
}
|
||||
void GuestLogin()
|
||||
{
|
||||
Console.Write("\nEnter your email address: ");
|
||||
string email = "";
|
||||
while (!Validation.ValidateEmail(email))
|
||||
{
|
||||
@@ -92,16 +65,234 @@ class Program
|
||||
if (!Validation.ValidateEmail(email))
|
||||
Console.Write("Please enter a valid email: ");
|
||||
}
|
||||
activeGuest = HotelManager.GetGuestByEmail(email);
|
||||
if (activeGuest == null)
|
||||
Console.WriteLine($"\nNo account was found with the email {email}.");
|
||||
Console.WriteLine($"\nYou have logged into {activeGuest.FirstName} {activeGuest.LastName} ({email}).");
|
||||
}
|
||||
void CreateNewGuestPrompt()
|
||||
{
|
||||
(string FirstName, string LastName) = GetGuestName();
|
||||
string Email = GetGuestEmail();
|
||||
Console.Write("Would you like to enter your credit card details? (Y/n): ");
|
||||
string? CreditCard = null;
|
||||
string? CardExpiration = null;
|
||||
string? CCV = null;
|
||||
if (Console.ReadLine().Equals("y") || Console.ReadLine().Equals("Y"))
|
||||
(CreditCard, CardExpiration, CCV) = GetCreditCardInformation();
|
||||
|
||||
activeGuest = HotelManager.CreateGuest(FirstName, LastName, Email, CreditCard: CreditCard, Expiration: CardExpiration, CCV: CCV);
|
||||
Console.Write($"You are now logged in as {FirstName} {LastName} ({Email})");
|
||||
}
|
||||
void UpdateGuestInformation()
|
||||
{
|
||||
if (activeGuest == null)
|
||||
{
|
||||
Console.WriteLine("No guest is currently logged in, please login.");
|
||||
return;
|
||||
}
|
||||
|
||||
string? NewFname = null, NewLname = null, NewEmail = null, NewCard = null, NewExpiry = null, NewCCV = null;
|
||||
|
||||
void SavePrompt()
|
||||
{
|
||||
if (NewFname == null && NewLname == null && NewEmail == null && NewCard == null && NewExpiry == null && NewCCV == null)
|
||||
{
|
||||
Console.WriteLine("No changes have been made.");
|
||||
return;
|
||||
}
|
||||
string changes = "";
|
||||
List<string> NewDetails = new List<string>();
|
||||
if (!string.IsNullOrEmpty(NewFname))
|
||||
{
|
||||
NewDetails.Add($"\tFirst Name: {activeGuest.FirstName} -> {NewFname}");
|
||||
activeGuest.FirstName = NewFname;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(NewLname))
|
||||
{
|
||||
NewDetails.Add($"\tLast Name: {activeGuest.LastName} -> {NewLname}");
|
||||
activeGuest.LastName = NewLname;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(NewEmail))
|
||||
{
|
||||
NewDetails.Add($"\tEmail: {activeGuest.Email} -> {NewEmail}");
|
||||
activeGuest.Email = NewEmail;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(NewCard))
|
||||
{
|
||||
NewDetails.Add($"\tCredit Card: {activeGuest.CreditCard} -> {NewCard}");
|
||||
activeGuest.CreditCard = NewCard;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(NewExpiry))
|
||||
{
|
||||
NewDetails.Add($"\tCard Expiration Date: {activeGuest.Expiration} -> {NewExpiry}");
|
||||
activeGuest.Expiration = NewExpiry;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(NewCCV))
|
||||
{
|
||||
NewDetails.Add($"\tCard CCV: {activeGuest.CCV} -> {NewCCV}");
|
||||
activeGuest.CCV = NewCCV;
|
||||
}
|
||||
if (NewDetails.Count > 0)
|
||||
changes += string.Join("\n", NewDetails);
|
||||
Console.WriteLine($"The following changes have been made:\n {changes}");
|
||||
HotelManager.UpdateGuest(activeGuest.Id, NewFname, NewLname, NewEmail, NewCard, NewExpiry, NewCCV);
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine($"You are currently logged in as {activeGuest.FirstName} {activeGuest.LastName} ({activeGuest.Email}).\n" +
|
||||
$"If this is not your account, please (Q)uit and log into your account. Changes will be recorded, but not saved\n" +
|
||||
$"until you enter S.\n");
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Please select the option you would like to change or enter S to save:\n" +
|
||||
"1. First Name and Last Name\n" +
|
||||
"2. Email Address\n" +
|
||||
"3. Credit Card Information\n");
|
||||
switch (Console.ReadLine())
|
||||
{
|
||||
case "Q": return;
|
||||
case "q": return;
|
||||
case "1": (NewFname, NewLname) = GetGuestName(); break;
|
||||
case "2": NewEmail = GetGuestEmail(); break;
|
||||
case "3": (NewCard, NewExpiry, NewCCV) = GetCreditCardInformation(); break;
|
||||
case "S": SavePrompt(); return;
|
||||
default: break;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
void CreateNewReservation()
|
||||
{
|
||||
if (activeGuest == null)
|
||||
Console.WriteLine("No guest is currently logged in, please login.");
|
||||
if (activeReservation != null)
|
||||
Console.WriteLine("");
|
||||
|
||||
string input = "";
|
||||
ReservationType SelectReservation()
|
||||
{
|
||||
Console.Write("What kind of reservation would you like to make?\n" +
|
||||
"1. Conventional\n" +
|
||||
"2. Prepaid\n" +
|
||||
"3. 60 Day Advance\n" +
|
||||
"4. Incentive\n" +
|
||||
"Input a number: ");
|
||||
while (true)
|
||||
{
|
||||
input = Console.ReadLine();
|
||||
if (input == "1" || input == "2" || input == "3" || input == "4")
|
||||
break;
|
||||
Console.Write("Please enter either 1, 2, 3, or 4: ");
|
||||
}
|
||||
return (ReservationType)Convert.ToInt32(input);
|
||||
}
|
||||
(DateTime, DateTime) SelectDate()
|
||||
{
|
||||
DateTime _StartDate;
|
||||
DateTime _EndDate;
|
||||
Console.Write("When would you like to begin your stay.\n" +
|
||||
"Your date input should be in in the following format - yyyy-MM-dd. Example: (2021-12-31)?\n" +
|
||||
"Input a date (2021-12-31): ");
|
||||
while(true)
|
||||
{
|
||||
input = Console.ReadLine();
|
||||
if (DateTime.TryParse(input, out _StartDate))
|
||||
break;
|
||||
|
||||
Console.Write("Please enter a valid date (2021-12-31): ");
|
||||
}
|
||||
Console.Write("When would you like to end your stay.\n" +
|
||||
"Your date input should be in in the following format - yyyy-MM-dd. Example: (2021-12-31)?\n" +
|
||||
"Input a date (2021-12-31): ");
|
||||
while (true)
|
||||
{
|
||||
input = Console.ReadLine();
|
||||
if (DateTime.TryParse(input, out _EndDate) && _EndDate > _StartDate)
|
||||
break;
|
||||
|
||||
if (_EndDate < _StartDate)
|
||||
Console.Write("End date cannot be before start date. Please enter a valid date (2021-12-31): ");
|
||||
else
|
||||
Console.Write("Please enter a valid date (2021-12-31): ");
|
||||
}
|
||||
return (_StartDate.Date, _EndDate.Date);
|
||||
}
|
||||
|
||||
ReservationType Type;
|
||||
DateTime StartDate;
|
||||
DateTime EndDate;
|
||||
|
||||
Type = SelectReservation();
|
||||
(StartDate, EndDate) = SelectDate();
|
||||
if (Type != ReservationType.SixtyDayAdvance &&
|
||||
(activeGuest.CreditCard == null || activeGuest.Expiration == null || activeGuest.CCV == null))
|
||||
GetCreditCardInformation();
|
||||
|
||||
Console.WriteLine($"Thank you for filling out your reservation details. Currently you have made a {Type}" +
|
||||
$"reservation and are scheduled to stay from {StartDate.ToString("yyyy-MM-dd")} to {EndDate.ToString("yyyy-MM-dd")}." +
|
||||
$"If these details are correct, enter YES to complete. If they are not enter...\n" +
|
||||
$"1. Change your reservation type\n" +
|
||||
$"2. Change your reservation dates\n" +
|
||||
$": ");
|
||||
input = Console.ReadLine();
|
||||
if (input != "YES")
|
||||
{
|
||||
bool completed = false;
|
||||
do
|
||||
{
|
||||
Console.Write("Would you like to edit any information, enter Q to exit and complete your reservation?\n" +
|
||||
"1. Reservation type\n" +
|
||||
"2. Reservation dates\n" +
|
||||
"Enter 1 or 2: ");
|
||||
switch (Console.ReadLine())
|
||||
{
|
||||
case "Q": completed = true; break;
|
||||
case "q": completed = true; break;
|
||||
case "1": SelectReservation(); break;
|
||||
case "2": SelectDate(); break;
|
||||
default: break;
|
||||
}
|
||||
} while (!completed);
|
||||
}
|
||||
HotelManager.CreateReservation(activeGuest, Type, DateTime.Now.Date, StartDate, EndDate);
|
||||
}
|
||||
(string?, string?, string?) GetCreditCardInformation()
|
||||
{
|
||||
Console.Write("What is your credit card number: ");
|
||||
string CreditCard = "";
|
||||
while (!Validation.ValidateCreditCard(CreditCard))
|
||||
{
|
||||
CreditCard = Console.ReadLine().Trim().Replace("\t", "");
|
||||
if (CreditCard == "q" || CreditCard == "Q")
|
||||
return (null, null, null);
|
||||
if (!Validation.ValidateCreditCard(CreditCard))
|
||||
Console.Write("Please enter a valid credit card. If your card is expired, enter Q to cancel: ");
|
||||
}
|
||||
Console.Write("What is your credit card expiration date (MM/yy): ");
|
||||
string CardExpiration = "";
|
||||
while (!Validation.ValidateExpirationDate(CardExpiration))
|
||||
{
|
||||
CardExpiration = Console.ReadLine().Trim().Replace("\t", "");
|
||||
if (CardExpiration == "q" || CardExpiration == "Q")
|
||||
return (null, null, null);
|
||||
if (!Validation.ValidateExpirationDate(CardExpiration))
|
||||
Console.Write("Please enter a valid expiration date. If your card is expired, enter Q to cancel: ");
|
||||
}
|
||||
Console.Write("What is your credit card CCV: ");
|
||||
string CCV = "";
|
||||
while (!Validation.ValidateCCV(CCV))
|
||||
{
|
||||
CCV = Console.ReadLine().Trim().Replace("\t", "");
|
||||
if (CCV == "q" || CCV == "Q")
|
||||
return (null, null, null);
|
||||
if (!Validation.ValidateCCV(CCV))
|
||||
Console.Write("Please enter a valid credit card CCV. If your card is expired, enter Q to cancel: ");
|
||||
}
|
||||
return (CreditCard, CardExpiration, CCV);
|
||||
}
|
||||
Console.Write(
|
||||
"Welcome to the Ophelias Oasis Hotel Registration System!\n" +
|
||||
"\nWelcome to the Ophelias Oasis Hotel Registration System!\n" +
|
||||
"Type help to get a full list of commands or enter a command.\n" +
|
||||
"Command: "
|
||||
);
|
||||
@@ -112,15 +303,16 @@ class Program
|
||||
switch(input)
|
||||
{
|
||||
case "help": help(); break;
|
||||
case "reservation create": break;
|
||||
case "reservation create": CreateNewReservation(); break;
|
||||
case "reservation update": break;
|
||||
case "reservation cancel": break;
|
||||
case "account create": CreateNewGuestPrompt(); break;
|
||||
case "account update": break;
|
||||
case "account update": UpdateGuestInformation(); break;
|
||||
case "account login": GuestLogin(); break;
|
||||
case "q": return;
|
||||
default: Console.WriteLine("Unknown command, enter help for more inforamtion."); break;
|
||||
}
|
||||
Console.Write("Command: ");
|
||||
Console.Write("\nCommand: ");
|
||||
}
|
||||
}
|
||||
private void AdminMode()
|
||||
|
||||
Reference in New Issue
Block a user