public JsonResult Action(StayTypeActionModels model) { JsonResult json = new JsonResult(); var result = false; if (model.Id > 0) { var staytype = StayTypeService.GetStayTypeById(model.Id); staytype.Name = model.Name; staytype.Desc = model.Desc; result = StayTypeService.UpdateStayType(staytype); } else { StayType stayType = new StayType(); stayType.Name = model.Name; stayType.Desc = model.Desc; result = StayTypeService.SaveStayType(stayType); } if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Xəta!" }; } return(json); }
public bool DeleteStayType(StayType stayType) { var context = new HotelBookingContext(); context.Entry(stayType).State = System.Data.Entity.EntityState.Deleted; return(context.SaveChanges() > 0); }
public bool SaveStayType(StayType stayType) { var context = new HotelBookingContext(); context.StayTypes.Add(stayType); return(context.SaveChanges() > 0); }
public void OnStayTypeChanged(object sender, StayType type) { var stayTypeChangeDelegate = StayTypeChanged as EventHandler <TypeChangedEventArgs>; if (stayTypeChangeDelegate != null) { stayTypeChangeDelegate(sender, new TypeChangedEventArgs { StayType = type }); } }
public BaseStay GetCharge(StayType stayType, DateTime start, DateTime end) { switch (stayType) { case StayType.ShortStay: return(new ShortStay(start, end)); case StayType.LongStay: return(new LongStay(start, end)); default: throw new InvalidOperationException($"Invalid stay type. Provided: {stayType}"); } }
public IParkingChargeCalculator GetParkingChargeCalculator(StayType staytype) { IParkingChargeCalculator parkingChargeCalculator = null; switch (staytype) { case StayType.ShortStay: { parkingChargeCalculator = (IParkingChargeCalculator)_serviceProvider.GetService(typeof(ShortStayParkingChargeCalculator)); break; } case StayType.LongStay: { parkingChargeCalculator = (IParkingChargeCalculator)_serviceProvider.GetService(typeof(LongStayParkingChargeCalculator)); break; } } return(parkingChargeCalculator); }