Files
ophelias-oasis/OpheliasOasis/Reporting/Accommodation.cs

27 lines
1.2 KiB
C#

using Ophelias.Models;
namespace Ophelias.Reporting
{
internal static class Accommodation
{
internal static void GenerateAccommodationBills(List<Reservation> reservations)
{
/*
* This function is used to format and create a new entry in the AccommodationBills.txt
* file. The accommodation bill details the guests Last, First name, the date they arrived,
* the date they depart/ departed, the length of their stay in days, and the amount they
* were charged.
*/
foreach (Reservation? r in reservations)
{
string report = $"ACCOMMODATION BILL - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
$"Name: {r.Guest.LastName}, {r.Guest.FirstName}\n" +
$"Arrival Date: {r.StartDate}\n" +
$"Departure Date: {r.EndDate}\n" +
$"Length of Stay: {(int)(r.EndDate.Date - r.StartDate.Date).TotalDays} days\n" +
$"Charged: ${r.Transaction.Owed}\n\n";
File.AppendAllText(Path.GetFullPath("AccommodationBills.txt"), report);
}
}
}
}