예제 #1
0
        public void CompleteApplication(BaseApplicationManager bam, string ToChoose, string PricePerNight)
        {
            string bamId   = bam.BaseApplicationId;
            var    baseApl = new MapperConfiguration(cfg => {
                cfg.CreateMap <BaseApplicationManager, Application>()
                .ForMember(f => f.NumOfPeople,
                           t => t.MapFrom(a => Convert.ToInt32(a.NumOfPeople)))
                .ForMember(f => f.Status, t => t.Ignore());
            }).CreateMapper().Map <Application>(bam);
            var r = new ReservedDates();

            r.DateStart      = DateTime.ParseExact(bam.DateIn, "yyyy-MM-dd", null);
            r.DateEnd        = DateTime.ParseExact(bam.DateOut, "yyyy-MM-dd", null);
            baseApl.ForDates = r;

            DateTime afttom = DateTime.Today.AddDays(2);

            if (afttom > r.DateStart)
            {
                afttom = r.DateStart;
            }
            baseApl.ExpirationDate = afttom;
            baseApl.Price          = Convert.ToInt32((r.DateEnd - r.DateStart).TotalDays) * baseApl.NumOfPeople * Convert.ToInt32(PricePerNight);
            _hotelContext.AddApplicationWithDeleting(baseApl, ToChoose, bamId);
        }
예제 #2
0
        public List <ApartmentView> GetAppropriateApartments(BaseApplicationManager av)
        {
            var all = _hotelContext.GetAllAppliableApartments().ToList();
            /**/
            var resap = (from ap in all
                         where (ap.Class == av.Class && Convert.ToInt32(av.NumOfPeople) < ap.AmountOfPeople &&
                                IsValidDateInterval(av.DateIn, av.DateOut, ap.Applications))
                         select ap).ToList();
            var baseApl = new MapperConfiguration(cfg => {
                cfg.CreateMap <Apartment, ApartmentView>()
                .ForMember(f => f.Description,
                           t => t.MapFrom(a => a.Description.Split(',')));
            }).CreateMapper().Map <List <ApartmentView> >(resap);

            return(baseApl);
        }
예제 #3
0
 public void DenyApplication(BaseApplicationManager bam)
 {
     _hotelContext.DenyApplication(Convert.ToInt32(bam.BaseApplicationId));
 }