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.
97 lines
3.1 KiB
C#
97 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Ophelias.Managers;
|
|
using System.Data.SQLite;
|
|
|
|
namespace Ophelias.Models
|
|
{
|
|
internal class Reservation
|
|
{
|
|
internal int Id;
|
|
internal Room Room;
|
|
internal Guest Guest;
|
|
internal Transaction Transaction;
|
|
|
|
internal bool IsNoShow;
|
|
|
|
internal ReservationType Type;
|
|
internal ReservationStatus Status;
|
|
|
|
internal DateTime CreationDate;
|
|
internal DateTime StartDate;
|
|
internal DateTime EndDate;
|
|
|
|
internal DateTime? CheckIn;
|
|
internal DateTime? CheckOut;
|
|
internal DateTime? DateChanged;
|
|
|
|
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)
|
|
{
|
|
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);
|
|
|
|
if (query == null)
|
|
throw new Exception();
|
|
|
|
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);
|
|
|
|
if (query == null)
|
|
throw new Exception();
|
|
|
|
cmd.CommandText = query;
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
internal enum ReservationStatus
|
|
{
|
|
Active,
|
|
Changed,
|
|
Cancelled,
|
|
Ended,
|
|
}
|
|
internal enum ReservationType
|
|
{
|
|
Conventional,
|
|
Prepaid,
|
|
Incentive,
|
|
SixtyDayAdvance,
|
|
}
|
|
}
|