public void AddApplication(StartFormViewModel st) { var baseApl = new MapperConfiguration(cfg => { cfg.CreateMap <StartFormViewModel, Application>() .ForMember(f => f.NumOfPeople, t => t.MapFrom(a => Convert.ToInt32(a.People))) .ForMember(f => f.Price, t => t.MapFrom(a => Convert.ToInt32(a.Price))); }).CreateMapper().Map <Application>(st); var r = new ReservedDates(); r.DateStart = DateTime.ParseExact(st.DateIn, "yyyy-MM-dd", null); r.DateEnd = DateTime.ParseExact(st.DateOut, "yyyy-MM-dd", null); baseApl.ForDates = r; DateTime afttom = DateTime.Today.AddDays(2); if (afttom > r.DateStart) { afttom = r.DateStart; } baseApl.ExpirationDate = afttom; _hotelContext.AddApplication(baseApl, Convert.ToInt32(st.ApId)); }
public void AddApplicationForAny(StartFormViewModel st) { var baseApl = new MapperConfiguration(cfg => { cfg.CreateMap <StartFormViewModel, BaseApplication>() .ForMember(f => f.NumOfPeople, t => t.MapFrom(a => Convert.ToInt32(a.People))) .ForMember(f => f.DateIn, t => t.MapFrom(a => DateTime.ParseExact(a.DateIn, "yyyy-MM-dd", null))) .ForMember(f => f.DateOut, t => t.MapFrom(a => DateTime.ParseExact(a.DateOut, "yyyy-MM-dd", null))); }).CreateMapper().Map <BaseApplication>(st); _hotelContext.AddApplicationForAny(baseApl); }