Files
ophelias-oasis/OpheliasOasis/Program.cs
雲華 306ac411b3 Further major refactoring of code
This is another commit to mostly version the code. There have been a
considerable number of changes and there is functionality that I am
still determining whether it should lie within the manager or the model
class itself. It makes the most sense to possibly add the "Update" or
database manipulation functions on the models themselves. On the other
hand, instead of creating and generating the ID in the model, the
current design is to create the entry in the database first, get the
last insert row ID and create a new and complete model that is returned
back by the function. This allows us to leverage the autoincrement
functionality of the database rather than trying to design a function
and/ or make an additional call to the database.

**NOTE: Code is non-functional due to some classes not having their
errors resolved.
2022-04-13 02:59:21 -04:00

174 lines
6.3 KiB
C#

using Ophelias.Models;
using Ophelias.Managers;
using Ophelias.Expressions;
using System.Data.SQLite;
class Program
{
private static void GuestMode()
{
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);
}
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 = "";
while (LastName.Length == 0)
{
LastName = Console.ReadLine();
if (LastName == "")
Console.Write("What is your last name: ");
}
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: ");
}
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();
}
Console.Write(
"Welcome to the Ophelias Oasis Hotel Registration System!\n" +
"Type help to get a full list of commands or enter a command.\n" +
"Command: "
);
while (true)
{
string? input = Console.ReadLine();
switch(input)
{
case "help": help(); break;
case "reservation create": break;
case "reservation update": break;
case "reservation cancel": break;
case "account create": CreateNewGuestPrompt(); break;
case "account update": break;
case "q": return;
default: Console.WriteLine("Unknown command, enter help for more inforamtion."); break;
}
Console.Write("Command: ");
}
}
private void AdminMode()
{
void help()
{
Console.WriteLine(
"Report Commands:\n" +
"\treservation create\n" +
"\treservation update\n" +
"\treservation cancel\n" +
"Account Commands:" +
"\taccount create\n" +
"\taccount update\n" +
"Enter Q to quit.\n"
);
return;
}
}
static void Main()
{
if (!File.Exists("database.sqlite3") || new FileInfo("database.sqlite3").Length == 0)
{
SQLiteConnection.CreateFile("database.sqlite3");
using (DatabaseManager Manager = new DatabaseManager())
{
Manager.InitializeTables();
Manager.InitializeRoomsTable();
}
}
bool run = true;
while (run)
{
Console.Write(
"Are you an employee or customer?\n" +
"1. Employee\n" +
"2. Customer/ Guest\n" +
": "
);
switch(Console.ReadLine().ToUpper())
{
case "1": break;
case "2": GuestMode(); break;
case "Q": run = false; break;
default: Console.WriteLine("You must either specify 1 for Employee, 2 for Customer/ Guest, or Q to quit.\n\n"); break;
}
}
}
}