public RoomRentalSlip CreateModel() { var roomRentalSlip = new RoomRentalSlip(this.RoomId, this.ConvertStringToDate(this.StartDate), this.ConvertStringToDate(this.EndDate)); foreach (var guestDto in this.Guests) { roomRentalSlip.Guests.Add(guestDto.CreateModel()); } return(roomRentalSlip); }
public bool UpdateRoomRentalSlip(RoomRentalSlip roomRentalSlip) { try { _context.RoomRentalSlips.AddOrUpdate(roomRentalSlip); _context.SaveChanges(); return(true); } catch { return(false); } }
public RoomRentalSlipDto(RoomRentalSlip roomRentalSlip) { this.Id = roomRentalSlip.Id; this.RoomId = roomRentalSlip.RoomId; this.StartDate = ConvertDateToString(roomRentalSlip.StartDate); this.EndDate = ConvertDateToString(roomRentalSlip.EndDate); this.Guests = new List <GuestDto>(); foreach (var guest in roomRentalSlip.Guests) { this.Guests.Add(new GuestDto(guest)); } }
public RoomRentalSlipFullInfoDto(RoomRentalSlip roomRentalSlip) { this.Id = roomRentalSlip.Id; this.RoomId = roomRentalSlip.RoomId; this.roomNumber = roomRentalSlip.Room.RoomNumber; this.roomCategory = roomRentalSlip.Room.RoomCategory.Name; this.StartDate = InvoiceDto.ConvertDateToString(roomRentalSlip.StartDate); this.EndDate = InvoiceDto.ConvertDateToString(roomRentalSlip.EndDate); this.HighestGuestCoefficient = roomRentalSlip.Guests.ToList()[0].GuestCategory.Coefficient; this.HighestGuestCoefficientName = roomRentalSlip.Guests.ToList()[0].GuestCategory.Name; foreach (var guest in roomRentalSlip.Guests) { if (this.HighestGuestCoefficient < guest.GuestCategory.Coefficient) { this.HighestGuestCoefficient = guest.GuestCategory.Coefficient; this.HighestGuestCoefficientName = guest.GuestCategory.Name; } } this.UnitPrice = roomRentalSlip.Room.RoomCategory.UnitPrice; this.NumStartSurcharge = roomRentalSlip.Room.RoomCategory.NumStartSurcharge; this.SurchargeRate = roomRentalSlip.Room.RoomCategory.SurchargeRate; this.Guests = new List <GuestDto>(); foreach (var guest in roomRentalSlip.Guests) { this.Guests.Add(new GuestDto(guest)); } this.Days = CalculationDifferentBetween2Days(StartDate, EndDate); if (this.Guests.Count < this.NumStartSurcharge) { this.TotalCost = HighestGuestCoefficient * UnitPrice * Days; } else { this.TotalCost = HighestGuestCoefficient * UnitPrice * Days + UnitPrice * this.SurchargeRate * Days; } }