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:
雲華
2022-04-13 23:53:17 -04:00
parent 306ac411b3
commit 8764c2e57c
7 changed files with 673 additions and 281 deletions

View File

@@ -1,19 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ophelias.Models;
using Ophelias.Managers;
using System.Data.SQLite;
namespace Ophelias.Models
{
internal class Reservation
{
internal int Id;
internal int RoomId;
internal int GuestId;
internal int TransactionId;
internal Room Room;
internal Guest Guest;
internal Transaction Transaction;
internal bool IsNoShow;
@@ -28,26 +26,57 @@ namespace Ophelias.Models
internal DateTime? CheckOut;
internal DateTime? DateChanged;
internal Reservation(int id, int gid, int tid, int room, ReservationType type, ReservationStatus status,
DateTime startdate, DateTime enddate)
internal Reservation(int Id, Guest Guest, Transaction Transaction, ReservationType Type, ReservationStatus Status,
DateTime CreationDate, DateTime StartDate, DateTime EndDate, bool IsNoShow = false, DateTime? CheckIn = null, DateTime? CheckOut = null, DateTime? DateChanged = null)
{
Id = id;
RoomId = room;
GuestId = gid;
TransactionId = tid;
this.Id = Id;
this.Guest = Guest;
this.Transaction = Transaction;
this.IsNoShow = IsNoShow;
this.Type = Type;
this.Status = Status;
this.CreationDate = CreationDate;
this.StartDate = StartDate;
this.EndDate = EndDate;
this.CheckIn = CheckIn;
this.CheckOut = CheckOut;
this.DateChanged = DateChanged;
}
internal void ChangeReservationDates(DateTime StartDate, DateTime EndDate)
{
this.StartDate = StartDate;
this.EndDate = EndDate;
DateChanged = DateTime.Now.Date;
using (DatabaseManager Manager = new DatabaseManager())
{
using (SQLiteCommand cmd = Manager.con.CreateCommand())
{
string? query = QueryBuilder.UpdateReservation(Id: Id, Status: ReservationStatus.Changed, StartDate: this.StartDate, EndDate: this.EndDate, DateChanged: DateChanged);
IsNoShow = false;
if (query == null)
throw new Exception();
Type = type;
Status = status;
cmd.CommandText = query;
cmd.ExecuteNonQuery();
}
}
Transaction.UpdateTransactionFees(HotelManager.GetBaseRate(), TxFunctions.Changed, TxFunctions.GetPayByDate(Type, this.StartDate, this.EndDate));
}
internal void CancelReservation()
{
using (DatabaseManager Manager = new DatabaseManager())
{
using (SQLiteCommand cmd = Manager.con.CreateCommand())
{
string? query = QueryBuilder.UpdateReservation(Id: Id, Status: ReservationStatus.Cancelled, DateChanged: DateTime.Now.Date);
CreationDate = DateTime.Now;
StartDate = startdate;
EndDate = enddate;
if (query == null)
throw new Exception();
CheckIn = null;
CheckOut = null;
DateChanged = null;
cmd.CommandText = query;
cmd.ExecuteNonQuery();
}
}
}
}
internal enum ReservationStatus