using Ophelias.Models; namespace Ophelias.Reporting { internal static class Operational { /* * This class is a collection of operational reporting operations. * The purpose of it is to write out information regarding the daily * arrivals and daily occupancy using fstring to print out the reports. * The output is not fully formatted as there is no way to accurately pad * the strings. If we knew the longest possible string, which we do not * because names can be any length, we chose to use tabs for the initial * spacing. */ internal static void FetchDailyArriavals(List reservations) { /* * This class gets writes the daily arrivals in the reservation list. * If there is a room number that is specified with an individual, * their room number is listed. Otherwise it is marked as N/A since * they have not checked in yet to recieve their room. */ List entries = new(); foreach (Reservation r in reservations) { string roominfo; if (!r.RoomNum.HasValue) { roominfo = "N/A"; } else { roominfo = r.RoomNum.Value.ToString(); } entries.Add($"{r.Guest.LastName}, {r.Guest.FirstName}\t{r.Type}\t{roominfo}\t{r.EndDate.Date.ToString("yyyy-MM-dd")}"); } string report = $"DAILY ARRIVAL REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" + $"Last, First\tType\tRoom\tDeparture\n" + $"{string.Join("\n", entries)}\n\n"; // Format the list joined into the string File.AppendAllText(Path.GetFullPath("DailyArrivals.txt"), report); // Write to file } internal static void FetchDailyOccupancy(List<(DateTime, int, string, string)> cop, List pop) { /* * Fetch Daily Occupancy gets the occupancy for that day. If the guest is leaving * the same day, an * will preceed their name. If the room they are in was occupied * the day before, a last occupied date is included. */ List entries = new(); foreach (var c in cop) { /* * Iterates over each item to determine whether a date and * * needs to be set based on the conditions detailed in the * docstring. */ string lastOccupied; string sameDayLeave = ""; if (pop.Contains(c.Item2)) { lastOccupied = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); } else { lastOccupied = "N/A"; } if(DateTime.Now.Date == c.Item1.Date) { sameDayLeave = "*"; } entries.Add($"{c.Item2}\t{lastOccupied}\t{sameDayLeave}{c.Item3}, {c.Item4}"); } string report = $"DAILY OCCUPANCY REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" + $"An * means that the guest is leaving the same day.\n" + $"Room #\tPrev. Occupied\tCurrent Occupant\n" + $"{string.Join("\n", entries)}\n\n"; // Format the list joined into the string File.AppendAllText(Path.GetFullPath("DailyOccupancy.txt"), report); // Write to file } } }