Beispiel #1
0
        public virtual RoomBookingDTO Compute(Client currentClient, int id, object param)
        {
            repo = (IRoomBookingRepository)base.repo;
            List <PeopleBooking> listPeopleBooking = null;
            List <Period>        listPeriod        = null;

            repo.includes.Add("Booking");
            repo.includes.Add("Room");
            ProcessDTOPostPut(null, id, currentClient);
            ValidateOrig();
            repo.includes.Add("PeopleCategory");
            listPeopleBooking = repo.GetPeopleBookingFromRoomBooking(orig.Id, currentClient.Id).ToList();
            listPeriod        = repo.GetPeriods((DateTime)orig.Booking.DateArrival, (DateTime)orig.Booking.DateDeparture, currentClient.Id).ToList();

            finalPriceHT  = 0;
            finalPriceTTC = 0;
            if (listPeopleBooking.Count == 0)
            {
                ComputeUniqPrice(listPeriod, currentClient);
            }
            else
            {
                ComputePricePerPerson(listPeopleBooking, listPeriod, currentClient);
            }
            if (!validationDictionnary.IsValid)
            {
                throw new ManahostValidationException(validationDictionnary);
            }
            orig.PriceHT  = finalPriceHT;
            orig.PriceTTC = finalPriceTTC;
            repo.Update(orig);
            repo.Save();
            return(GetMapper.Map <RoomBooking, RoomBookingDTO>(orig));
        }
Beispiel #2
0
 protected override void DoPostAfterSave(Client currentClient, RoomBooking entity, object param)
 {
     if (entity.DateBegin == null || entity.DateEnd == null)
     {
         if (entity.DateBegin == null)
         {
             entity.DateBegin = entity.Booking.DateArrival;
         }
         if (entity.DateEnd == null)
         {
             entity.DateEnd = entity.Booking.DateDeparture;
         }
         ComputeNbNights(entity);
         repo.Update(entity);
         repo.Save();
     }
 }