Esempio n. 1
0
        private int CalculationDifferentBetween2Days(string startDateStr, string endDateStr)
        {
            var startDate = InvoiceDto.ConvertStringToDate(startDateStr);
            var endDate   = InvoiceDto.ConvertStringToDate(endDateStr);

            var totalDays = (endDate - startDate).Days;

            return(totalDays);
        }
Esempio n. 2
0
        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;
            }
        }
        public InvoiceFullInfoDto(Invoice invoice)
        {
            this.ID            = invoice.ID;
            this.GuestId       = invoice.GuestId;
            this.GuestName     = invoice.Guest.Name;
            this.GuestCMND     = invoice.Guest.CMND;
            this.DateOfInvoice = InvoiceDto.ConvertDateToString(invoice.DateOfInvoice);
            this.TotalCost     = 0;

            this.RoomRentalSlipFullInfoDtos = new List <RoomRentalSlipFullInfoDto>();

            foreach (var roomRentalSlip in invoice.RoomRentalSlips)
            {
                this.RoomRentalSlipFullInfoDtos.Add(new RoomRentalSlipFullInfoDto(roomRentalSlip));
            }

            foreach (var roomRentalSlip in this.RoomRentalSlipFullInfoDtos)
            {
                this.TotalCost += roomRentalSlip.TotalCost;
            }
        }