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.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Ophelias.Models;
|
||||
using Ophelias.Managers;
|
||||
using Ophelias.Expressions;
|
||||
using System.Data.SQLite;
|
||||
|
||||
class Program
|
||||
@@ -8,8 +9,7 @@ class Program
|
||||
{
|
||||
Reservation? activeReservation = null;
|
||||
Guest? activeGuest = null;
|
||||
TransactionTableManager tx = new TransactionTableManager(null);
|
||||
tx.UpdateTransactionInfo(1);
|
||||
|
||||
void help()
|
||||
{
|
||||
Console.WriteLine(
|
||||
@@ -17,7 +17,7 @@ class Program
|
||||
"\treservation create\n" +
|
||||
"\treservation update\n" +
|
||||
"\treservation cancel\n" +
|
||||
"Account Commands:" +
|
||||
"Account Commands:\n" +
|
||||
"\taccount create\n" +
|
||||
"\taccount update\n" +
|
||||
"Enter Q to quit.\n"
|
||||
@@ -25,18 +25,89 @@ class Program
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateNewReservation()
|
||||
{
|
||||
Reservation newReservation;
|
||||
}
|
||||
|
||||
while(true)
|
||||
void CreateNewGuestPrompt()
|
||||
{
|
||||
Console.WriteLine(
|
||||
(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)
|
||||
{
|
||||
@@ -44,11 +115,12 @@ class Program
|
||||
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()
|
||||
@@ -70,15 +142,25 @@ class Program
|
||||
}
|
||||
static void Main()
|
||||
{
|
||||
SQLiteConnection.CreateFile("OpheliasOasis.sqlite");
|
||||
|
||||
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.WriteLine(
|
||||
Console.Write(
|
||||
"Are you an employee or customer?\n" +
|
||||
"1. Employee\n" +
|
||||
"2. Customer/ Guest"
|
||||
"2. Customer/ Guest\n" +
|
||||
": "
|
||||
);
|
||||
switch(Console.ReadLine().ToUpper())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user