First major version of the project
This finishes the first iteration of the project. Reports have been tested and are functional in terms of writing out and outputting some form of text. There are still a few bugs here and there that are found but ultimately this commit is so testing can begin. Since the changes are too large to individually summarize, here is the generalization: Reports have been integrated into the admin mode. They write out to text files rather than export to say email or a printer as it was not to be considered for this version. The files are appended too and exist in the debug director of the project. I made this easier to find by outputting where the files were output to after running the report. Other changes included some bug fixes, optimizations, and a few bit of automatic cleanup. This may lead to sylistic inconsistencies. Documentation will come in a later commit.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using Ophelias.Models;
|
||||
using Ophelias.Expressions;
|
||||
using Ophelias.Managers;
|
||||
using Ophelias.Expressions;
|
||||
using Ophelias.Models;
|
||||
using Ophelias.Reporting;
|
||||
using System.Data.SQLite;
|
||||
|
||||
class Program
|
||||
internal class Program
|
||||
{
|
||||
private static string GetGuestEmail()
|
||||
{
|
||||
@@ -13,7 +14,9 @@ class Program
|
||||
{
|
||||
Email = Console.ReadLine();
|
||||
if (!Validation.ValidateEmail(Email))
|
||||
{
|
||||
Console.Write("Please enter a valid email: ");
|
||||
}
|
||||
}
|
||||
return Email;
|
||||
}
|
||||
@@ -46,9 +49,14 @@ class Program
|
||||
{
|
||||
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 = "";
|
||||
@@ -56,9 +64,14 @@ class Program
|
||||
{
|
||||
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 = "";
|
||||
@@ -66,20 +79,28 @@ class Program
|
||||
{
|
||||
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() {
|
||||
(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: ");
|
||||
}
|
||||
}
|
||||
Console.Write("What is your last name: ");
|
||||
string LastName = "";
|
||||
@@ -87,7 +108,9 @@ class Program
|
||||
{
|
||||
LastName = Console.ReadLine();
|
||||
if (LastName == "")
|
||||
{
|
||||
Console.Write("What is your last name: ");
|
||||
}
|
||||
}
|
||||
return (FirstName, LastName);
|
||||
}
|
||||
@@ -99,16 +122,18 @@ class Program
|
||||
{
|
||||
email = Console.ReadLine();
|
||||
if (!Validation.ValidateEmail(email))
|
||||
{
|
||||
Console.Write("Please enter a valid email: ");
|
||||
}
|
||||
}
|
||||
activeGuest = HotelManager.GetGuestByEmail(email);
|
||||
activeGuest = Hotel.GetGuestByEmail(email);
|
||||
if (activeGuest == null)
|
||||
{
|
||||
Console.WriteLine($"\nNo account was found with the email {email}.");
|
||||
return;
|
||||
}
|
||||
Console.WriteLine($"\nYou have logged into {activeGuest.FirstName} {activeGuest.LastName} ({email}).");
|
||||
activeReservation = HotelManager.GetResByGuest(activeGuest);
|
||||
activeReservation = Hotel.GetResByGuest(activeGuest);
|
||||
}
|
||||
void CreateNewGuestPrompt()
|
||||
{
|
||||
@@ -118,10 +143,25 @@ class Program
|
||||
string? CreditCard = null;
|
||||
string? CardExpiration = null;
|
||||
string? CCV = null;
|
||||
if (Console.ReadLine().Equals("y") || Console.ReadLine().Equals("Y"))
|
||||
(CreditCard, CardExpiration, CCV) = GetCreditCardInformation();
|
||||
while (true)
|
||||
{
|
||||
string input = Console.ReadLine();
|
||||
if (input.Equals("y") || input.Equals("Y"))
|
||||
{
|
||||
(CreditCard, CardExpiration, CCV) = GetCreditCardInformation();
|
||||
break;
|
||||
}
|
||||
else if (input.Equals("n") || input.Equals("N"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write("Input must be Y, y or N, n: ");
|
||||
}
|
||||
}
|
||||
|
||||
activeGuest = new Guest(FirstName, LastName, Email, CreditCard: CreditCard, Expiration: CardExpiration, CCV: CCV);
|
||||
activeGuest = new(FirstName, LastName, Email, CreditCard: CreditCard, Expiration: CardExpiration, CCV: CCV);
|
||||
Console.Write($"You are now logged in as {FirstName} {LastName} ({Email})");
|
||||
}
|
||||
void UpdateGuestInformation()
|
||||
@@ -133,7 +173,7 @@ class Program
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -142,10 +182,10 @@ class Program
|
||||
return;
|
||||
}
|
||||
string changes = "";
|
||||
List<string> NewDetails = new List<string>();
|
||||
List<string> NewDetails = new();
|
||||
if (!string.IsNullOrEmpty(NewFname))
|
||||
{
|
||||
NewDetails.Add($"\tFirst Name: {activeGuest.FirstName} -> {NewFname}");
|
||||
NewDetails.Add($"\tFirst Name: {activeGuest.FirstName} -> {NewFname}");
|
||||
activeGuest.FirstName = NewFname;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(NewLname))
|
||||
@@ -174,7 +214,10 @@ class Program
|
||||
activeGuest.CCV = NewCCV;
|
||||
}
|
||||
if (NewDetails.Count > 0)
|
||||
{
|
||||
changes += string.Join("\n", NewDetails);
|
||||
}
|
||||
|
||||
Console.WriteLine($"The following changes have been made:\n {changes}");
|
||||
activeGuest.UpdateGuest(activeGuest.Id, NewFname, NewLname, NewEmail, NewCard, NewExpiry, NewCCV);
|
||||
return;
|
||||
@@ -214,7 +257,10 @@ class Program
|
||||
{
|
||||
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) - 1);
|
||||
@@ -223,7 +269,7 @@ class Program
|
||||
{
|
||||
if (Type == ReservationType.Prepaid)
|
||||
{
|
||||
if ((Date - DateTime.Now).TotalDays < 90)
|
||||
if ((int)(Date - DateTime.Now).TotalDays < 90)
|
||||
{
|
||||
Console.WriteLine("Prepaid reservations must be made 90 days in advance.");
|
||||
}
|
||||
@@ -234,7 +280,7 @@ class Program
|
||||
}
|
||||
else if (Type == ReservationType.SixtyDayAdvance)
|
||||
{
|
||||
if ((Date - DateTime.Now).TotalDays < 60)
|
||||
if ((int)(Date - DateTime.Now).TotalDays < 60)
|
||||
{
|
||||
Console.WriteLine("Sixty-days-in-advance reservations must be made 60 days in advance.");
|
||||
}
|
||||
@@ -260,12 +306,18 @@ class Program
|
||||
{
|
||||
input = Console.ReadLine();
|
||||
if (DateTime.TryParse(input, out _StartDate) && _StartDate >= DateTime.Now)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (_StartDate <= DateTime.Now)
|
||||
{
|
||||
Console.Write("Start date cannot be before current date. Please enter a valid date (2021-12-31): ");
|
||||
}
|
||||
else
|
||||
{
|
||||
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" +
|
||||
@@ -274,12 +326,18 @@ class Program
|
||||
{
|
||||
input = Console.ReadLine();
|
||||
if (DateTime.TryParse(input, out _EndDate) && _EndDate > _StartDate)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (_EndDate < _StartDate)
|
||||
{
|
||||
Console.Write("End date must be after 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);
|
||||
}
|
||||
@@ -293,7 +351,10 @@ class Program
|
||||
bool maxCapacity = false;
|
||||
(StartDate, EndDate) = Dates();
|
||||
if (StartDate == null || EndDate == null)
|
||||
(_, maxCapacity) = HotelManager.AvgOccupancySpan(StartDate, EndDate);
|
||||
{
|
||||
(_, maxCapacity) = Hotel.AvgOccupancySpan(StartDate, EndDate);
|
||||
}
|
||||
|
||||
if (!maxCapacity)
|
||||
{
|
||||
if (!CheckReservationRestrictions(StartDate, Type))
|
||||
@@ -306,7 +367,8 @@ class Program
|
||||
Console.WriteLine("Aborting reservation changes.");
|
||||
return (null, null);
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -318,7 +380,7 @@ class Program
|
||||
|
||||
}
|
||||
return (StartDate, EndDate);
|
||||
|
||||
|
||||
}
|
||||
void EditReservationPrompt()
|
||||
{
|
||||
@@ -340,17 +402,22 @@ class Program
|
||||
case "Q": Console.WriteLine("Changes have has been deleted."); return;
|
||||
case "1": NewType = SelectReservation(); break;
|
||||
case "2": (NewStartDate, NewEndDate) = SelectDate(NewType); break;
|
||||
case "S":
|
||||
case "S":
|
||||
if (NewStartDate == null || NewEndDate == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (CheckReservationRestrictions((DateTime)NewStartDate, NewType))
|
||||
{
|
||||
(NewStartDate, NewEndDate) = SelectDate(NewType);
|
||||
if (NewStartDate == null || NewEndDate == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
completed = true;
|
||||
(activeReservation.Type, activeReservation.StartDate, activeReservation.EndDate) = (NewType, (DateTime)NewStartDate, (DateTime)NewEndDate);
|
||||
(activeReservation.Type, activeReservation.StartDate, activeReservation.EndDate) = (NewType, (DateTime)NewStartDate, (DateTime)NewEndDate);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
@@ -368,7 +435,7 @@ class Program
|
||||
Console.WriteLine("You currently have an active registration.");
|
||||
return;
|
||||
}
|
||||
if (HotelManager.GetBaseRate() == null)
|
||||
if (Hotel.GetBaseRate() == null)
|
||||
{
|
||||
Console.WriteLine("Unable to proceed with reservation due to no base rate being set. Please inform an employee.");
|
||||
return;
|
||||
@@ -388,14 +455,18 @@ class Program
|
||||
return;
|
||||
}
|
||||
|
||||
while((Type != ReservationType.SixtyDayAdvance &&
|
||||
(activeGuest.CreditCard == null || activeGuest.Expiration == null || activeGuest.CCV == null))) {
|
||||
while ((Type != ReservationType.SixtyDayAdvance &&
|
||||
(activeGuest.CreditCard == null || activeGuest.Expiration == null || activeGuest.CCV == null)))
|
||||
{
|
||||
Console.Write("The reservation type you chose requires you to specify your credit card.\n" +
|
||||
"If you are unable to provide one, enter Q to quit or hit enter to continue.\n" +
|
||||
": ");
|
||||
input = Console.ReadLine();
|
||||
if (input == "Q")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GetCreditCardInformation();
|
||||
}
|
||||
|
||||
@@ -404,13 +475,14 @@ class Program
|
||||
$"If these details are correct, enter YES to complete. To cancel your reservation enter Q.\n" +
|
||||
$": ");
|
||||
input = Console.ReadLine();
|
||||
while(input != "YES")
|
||||
while (input != "YES")
|
||||
{
|
||||
if (input == "Q")
|
||||
{
|
||||
Console.WriteLine("Reservation has been deleted.");
|
||||
return;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write("Input must be YES or Q.\n: ");
|
||||
input = Console.ReadLine();
|
||||
@@ -418,9 +490,13 @@ class Program
|
||||
}
|
||||
if (Type == ReservationType.Prepaid)
|
||||
{
|
||||
activeReservation = new Reservation(activeGuest, Type, DateTime.Now.Date, StartDate.Value, EndDate.Value);
|
||||
activeReservation = new(activeGuest, Type, DateTime.Now.Date, StartDate.Value, EndDate.Value);
|
||||
activeReservation.Transaction.Pay(activeReservation.Transaction.Owed);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeReservation = new(activeGuest, Type, DateTime.Now.Date, StartDate.Value, EndDate.Value);
|
||||
}
|
||||
Console.WriteLine("Your reservation has been made.");
|
||||
}
|
||||
void UpdateReservation()
|
||||
@@ -447,13 +523,17 @@ class Program
|
||||
{
|
||||
(_StartDate, _EndDate) = SelectDate(activeReservation.Type);
|
||||
if (_StartDate.HasValue && _EndDate.HasValue)
|
||||
{
|
||||
Console.Write("Your new reservation details are:\n" +
|
||||
$"\tStarts on: {activeReservation.StartDate.ToString("yyyy-MM-dd")} -> {_StartDate.Value.ToString("yyyy-MM-dd")}\n" +
|
||||
$"\tEnds on: {activeReservation.EndDate.ToString("yyyy-MM-dd")} -> {_EndDate.Value.ToString("yyyy-MM-dd")}\n");
|
||||
}
|
||||
|
||||
Console.Write("Are you done with your changes?\n" +
|
||||
"Enter YES to finish and save, NO to continue editing.\n" +
|
||||
": ");
|
||||
} else if (input == "Q")
|
||||
}
|
||||
else if (input == "Q")
|
||||
{
|
||||
Console.WriteLine("Your changes have been discarded.");
|
||||
return;
|
||||
@@ -489,13 +569,14 @@ class Program
|
||||
"You may be charged depending on your reservation.\n" +
|
||||
"Enter YES to confirm or NO to exit: ");
|
||||
input = Console.ReadLine();
|
||||
while(input != "YES")
|
||||
while (input != "YES")
|
||||
{
|
||||
if (input == "NO")
|
||||
{
|
||||
Console.Write("Reservation has not been cancelled.");
|
||||
return;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write("Your input must be YES or NO: ");
|
||||
Console.ReadLine();
|
||||
@@ -512,16 +593,16 @@ class Program
|
||||
);
|
||||
while (true)
|
||||
{
|
||||
|
||||
|
||||
string? input = Console.ReadLine();
|
||||
switch(input)
|
||||
switch (input)
|
||||
{
|
||||
case "help": help(); break;
|
||||
case "reservation create": CreateNewReservation(); break;
|
||||
case "reservation update": UpdateReservation(); break;
|
||||
case "reservation cancel": CancelReservation(); break;
|
||||
case "account create": CreateNewGuestPrompt(); break;
|
||||
case "account update": UpdateGuestInformation(); 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;
|
||||
@@ -535,9 +616,9 @@ class Program
|
||||
{
|
||||
Console.WriteLine(
|
||||
"Report Commands:\n" +
|
||||
"\tgenerate daily report - Generates a daily report on expected occupancy, room income, and incentive losses.\n" +
|
||||
"\tgenerate management report - Generates a daily management report on expected occupancy, room income, and incentive losses.\n" +
|
||||
"\tgenerate operational report - Generates a report of daily arrivals and occupancy.\n" +
|
||||
"\tgenerate accomodation bills - Generates an accomodation bill that will be handed to guests upon checkout.\n" +
|
||||
"\tgenerate accommodation bills - Generates an accommodation bill that will be handed to guests upon checkout.\n" +
|
||||
"\treservation cancel\n" +
|
||||
"Management Commands:" +
|
||||
"\nnotify pending payments - Generates and emails 60 day advance reservations that they must pay for their reservation or it will be cancelled." +
|
||||
@@ -578,9 +659,26 @@ class Program
|
||||
{
|
||||
if (FixedDate != null)
|
||||
{
|
||||
HotelManager.SetBaseRate(Convert.ToDouble(amount), (DateTime)FixedDate);
|
||||
Console.WriteLine($"A base rate of {amount} has been set and will take effect on {FixedDate.Value.ToString("yyyy-MM-dd")}.");
|
||||
} else
|
||||
if (Hotel.GetBaseRateByDate((DateTime)FixedDate))
|
||||
{
|
||||
Console.Write("There is already a base rate configured for this date.\n" +
|
||||
"If you are entering a new rate because one was not configured and got this error, type YES.\n" +
|
||||
"Would you like to overwrite it (YES)? If not enter anything to continue.\n" +
|
||||
": ");
|
||||
if (Console.ReadLine() == "YES")
|
||||
{
|
||||
Hotel.UpdateBaseRate(Convert.ToDouble(amount), FixedDate.Value.Date, DefaultRate: true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Hotel.SetBaseRate(Convert.ToDouble(amount), (DateTime)FixedDate, true);
|
||||
}
|
||||
|
||||
Console.WriteLine($"A base rate of {amount} has been set and will take effect immediately.");
|
||||
}
|
||||
else
|
||||
{
|
||||
DateTime StartDate;
|
||||
Console.Write("When would you like the new rate to take effect.\n" +
|
||||
@@ -590,28 +688,31 @@ class Program
|
||||
{
|
||||
input = Console.ReadLine();
|
||||
if (DateTime.TryParse(input, out StartDate))
|
||||
{
|
||||
if (StartDate.Date <= DateTime.Now.Date)
|
||||
{
|
||||
Console.WriteLine("Base rate must be configured for a future night. Not the same day or past.");
|
||||
}
|
||||
else if (HotelManager.GetBaseRateByDate(StartDate))
|
||||
else if (Hotel.GetBaseRateByDate(StartDate))
|
||||
{
|
||||
|
||||
Console.Write("There is already a base rate configured for this date.\n" +
|
||||
"Would you like to overwrite it (YES)? If not enter anything to continue." +
|
||||
": ");
|
||||
if(Console.ReadLine() == "YES")
|
||||
if (Console.ReadLine() == "YES")
|
||||
{
|
||||
HotelManager.UpdateBaseRate(Convert.ToDouble(amount), StartDate.Date);
|
||||
Hotel.UpdateBaseRate(Convert.ToDouble(amount), StartDate.Date);
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Console.Write("Please enter a valid date (2021-12-31): ");
|
||||
}
|
||||
HotelManager.SetBaseRate(Convert.ToDouble(amount), StartDate);
|
||||
Hotel.SetBaseRate(Convert.ToDouble(amount), StartDate);
|
||||
Console.WriteLine($"A base rate of {amount} has been set and will take effect on {DateTime.Now.Date.ToString("yyyy-MM-dd")}.");
|
||||
}
|
||||
return true;
|
||||
@@ -625,13 +726,14 @@ class Program
|
||||
return false;
|
||||
}
|
||||
|
||||
if (HotelManager.GetBaseRate() == null)
|
||||
if (Hotel.GetBaseRate() == null)
|
||||
{
|
||||
Console.Write("No base rate has been configured. " +
|
||||
"You must set one for the current date.\n" +
|
||||
"Enter new rate: ");
|
||||
while (!SetRatePrompt(DateTime.Now.Date)) { }
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write("What is the value of the rate you would like to set.\n" +
|
||||
"Enter new rate: ");
|
||||
@@ -641,8 +743,8 @@ class Program
|
||||
void CheckIn()
|
||||
{
|
||||
string Email = GetGuestEmail();
|
||||
TimeRefs? status = HotelManager.CanBeCheckedIn(Email);
|
||||
Guest? g = HotelManager.GetGuestByEmail(Email);
|
||||
TimeRefs? status = Hotel.CanBeCheckedIn(Email);
|
||||
Guest? g = Hotel.GetGuestByEmail(Email);
|
||||
if (g == null)
|
||||
{
|
||||
Console.WriteLine("No guest with that email exists.");
|
||||
@@ -656,17 +758,22 @@ class Program
|
||||
|
||||
if (status.Value == TimeRefs.OnTime)
|
||||
{
|
||||
int? RoomID = HotelManager.CheckInGuest(Email, DateTime.Now.Date);
|
||||
int? RoomID = Hotel.CheckInGuest(Email, DateTime.Now.Date);
|
||||
if (RoomID != null)
|
||||
{
|
||||
Console.WriteLine($"Guest has been checked in, their room number is {RoomID}.");
|
||||
}
|
||||
}
|
||||
else if (status.Value == TimeRefs.Late)
|
||||
{
|
||||
Console.WriteLine("Since the reservation was not checked in on the date scheduled, it has been cancelled. The guest will be charged the \"no show\" penalty.");
|
||||
Reservation? r = HotelManager.GetResByGuest(g);
|
||||
Reservation? r = Hotel.GetResByGuest(g);
|
||||
|
||||
if (r == null)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
r.CancelReservation();
|
||||
|
||||
}
|
||||
@@ -679,16 +786,97 @@ class Program
|
||||
void CheckOut()
|
||||
{
|
||||
string Email = GetGuestEmail();
|
||||
if (HotelManager.GuestCurrentlyCheckedIn(Email))
|
||||
if (Hotel.GuestCurrentlyCheckedIn(Email))
|
||||
{
|
||||
HotelManager.CheckOutGuest(Email, DateTime.Now.Date);
|
||||
Reservation r = Hotel.GetResByGuest(Hotel.GetGuestByEmail(Email));
|
||||
if (r.Type == ReservationType.Incentive || r.Type == ReservationType.Conventional)
|
||||
{
|
||||
r.Transaction.Pay(r.Transaction.Owed);
|
||||
}
|
||||
|
||||
Hotel.CheckOutGuest(Email, DateTime.Now.Date);
|
||||
Console.WriteLine($"Guest has been checked out.");
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Can't checkout a guest that hasn't been checked in.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
void NotifyOutstandingPayments()
|
||||
{
|
||||
List<Reservation> activeSixtyRes = Hotel.GetActiveSixtyDayRes();
|
||||
foreach (Reservation r in activeSixtyRes)
|
||||
{
|
||||
int days = (int)(r.StartDate.Date - DateTime.Now.Date).TotalDays - 30;
|
||||
if (days < 0)
|
||||
{
|
||||
r.CancelReservation();
|
||||
}
|
||||
else if (days <= 15)
|
||||
{
|
||||
Email e = new(r.Guest.Email);
|
||||
e.Send();
|
||||
}
|
||||
}
|
||||
if (File.Exists("Emails.txt"))
|
||||
{
|
||||
FileInfo f = new("Emails.txt");
|
||||
Console.WriteLine($"Emails have been written and appended to {f.FullName}");
|
||||
}
|
||||
}
|
||||
void GenerateManagementReports()
|
||||
{
|
||||
var w = Hotel.GetExpectedOccupancyCount();
|
||||
Management.CalculateExpectedOccupancy(w.Item2, w.Item1);
|
||||
if (File.Exists("ExpectedOccupancy.txt"))
|
||||
{
|
||||
FileInfo f = new("ExpectedOccupancy.txt");
|
||||
Console.WriteLine($"Expected occupancy has been written and appended to {f.FullName}");
|
||||
}
|
||||
var x = Hotel.GetExpectedIncomeCount();
|
||||
Management.CalculateExpectedIncome(x.Item1, x.Item2, x.Item3);
|
||||
if (File.Exists("ExpectedIncome.txt"))
|
||||
{
|
||||
FileInfo f = new("ExpectedIncome.txt");
|
||||
Console.WriteLine($"Expected income has been written and appended to {f.FullName}");
|
||||
}
|
||||
var y = Hotel.GetIncentiveTransactions();
|
||||
Management.CalculateIncentiveLosses(y.Item3, y.Item1, y.Item2);
|
||||
if (File.Exists("IncentiveLosses.txt"))
|
||||
{
|
||||
FileInfo f = new("IncentiveLosses.txt");
|
||||
Console.WriteLine($"Incentive losses have been written and appended to {f.FullName}");
|
||||
}
|
||||
}
|
||||
void GenerateAccommodationBills()
|
||||
{
|
||||
List<Reservation> reservations = Hotel.GetDailyArrivals();
|
||||
Accommodation.GenerateAccommodationBills(reservations);
|
||||
|
||||
if (File.Exists("AccommodationBills.txt"))
|
||||
{
|
||||
FileInfo f = new("AccommodationBills.txt");
|
||||
Console.WriteLine($"Accommodation bills have been written and appended to {f.FullName}");
|
||||
}
|
||||
}
|
||||
void GenerateOperationalReports()
|
||||
{
|
||||
List<Reservation> reservations = Hotel.GetDailyArrivals();
|
||||
Operational.FetchDailyArriavals(reservations);
|
||||
if (File.Exists("DailyArrivals.txt"))
|
||||
{
|
||||
FileInfo f = new("DailyArrivals.txt");
|
||||
Console.WriteLine($"Daily arrivals have been written and appended to {f.FullName}");
|
||||
}
|
||||
var x = Hotel.GetDailyOccupancy();
|
||||
Operational.FetchDailyOccupancy(x.Item1, x.Item2);
|
||||
if (File.Exists("DailyOccupancy.txt"))
|
||||
{
|
||||
FileInfo f = new("DailyOccupancy.txt");
|
||||
Console.WriteLine($"Daily occupancy has been written and appended to {f.FullName}");
|
||||
}
|
||||
}
|
||||
|
||||
Console.Write(
|
||||
"\nWelcome to the Ophelias Oasis Hotel Management System!\n" +
|
||||
@@ -701,10 +889,10 @@ class Program
|
||||
switch (input)
|
||||
{
|
||||
case "help": help(); break;
|
||||
case "generate daily report": break;
|
||||
case "generate operational report": break;
|
||||
case "generate accomodation bills": break;
|
||||
case "notify pending payments": break;
|
||||
case "generate management report": GenerateManagementReports(); break;
|
||||
case "generate operational report": GenerateOperationalReports(); break;
|
||||
case "generate accommodation bills": GenerateAccommodationBills(); break;
|
||||
case "notify pending payments": NotifyOutstandingPayments(); break;
|
||||
case "issue penalties": break;
|
||||
case "checkin guest": CheckIn(); break;
|
||||
case "checkout guest": CheckOut(); break;
|
||||
@@ -716,18 +904,22 @@ class Program
|
||||
}
|
||||
|
||||
}
|
||||
static void Main()
|
||||
|
||||
private static void Main()
|
||||
{
|
||||
HotelManager.CheckBaseRate();
|
||||
if (!File.Exists("database.sqlite3") || new FileInfo("database.sqlite3").Length == 0)
|
||||
{
|
||||
SQLiteConnection.CreateFile("database.sqlite3");
|
||||
using (DatabaseManager Manager = new DatabaseManager())
|
||||
using (Database Manager = new())
|
||||
{
|
||||
Manager.InitializeTables();
|
||||
Manager.InitializeRoomsTable();
|
||||
}
|
||||
}
|
||||
if (!Hotel.CheckBaseRate())
|
||||
{
|
||||
Console.WriteLine("No base rate is configured. As a result reservations cannot be made until one is configured.");
|
||||
}
|
||||
|
||||
bool run = true;
|
||||
while (run)
|
||||
@@ -738,7 +930,7 @@ class Program
|
||||
"2. Customer/ Guest\n" +
|
||||
": "
|
||||
);
|
||||
switch(Console.ReadLine().ToUpper())
|
||||
switch (Console.ReadLine().ToUpper())
|
||||
{
|
||||
case "1": AdminMode(); break;
|
||||
case "2": GuestMode(); break;
|
||||
|
||||
Reference in New Issue
Block a user