public JsonResult CreateActionSetting(ActionSettingVM model) { try { if (!ModelState.IsValid) { return(Json(null)); } else { var ActionSettingExist = UnitOfWork.ActionSettingBL.CheckExist(b => b.ReservationStatusId == model.ReservationStatusId && b.ActionStepId == model.ActionStepId && b.BranchId == model.BranchId && b.RateSegmentCategoryId == model.RateSegmentCategoryId && b.WeekDayId == model.WeekDayId); if (ActionSettingExist) { return(Json(new { success = false, Message = "Action setting already exists" })); } var ActionSetting = new ActionSetting { ReservationStatusId = model.ReservationStatusId, ActionStepId = model.ActionStepId, BranchId = model.BranchId, RateSegmentCategoryId = model.RateSegmentCategoryId, WeekDayId = model.WeekDayId, }; if (model.IsEnable == null || model.IsEnable == true) { ActionSetting.IsEnable = true; } else { ActionSetting.IsEnable = false; } UnitOfWork.ActionSettingBL.Add(ActionSetting); if (UnitOfWork.Complete() > 0) { return(Json(new { success = true, Message = "Action setting added successfully" })); } else { return(Json(new { success = false, Message = "Failed to add Action setting" })); } } } catch (Exception) { return(Json(new { success = false, Message = "An error occured , please try again later" })); } }
public JsonResult UpdateActionSetting(ActionSettingVM model) { try { if (!ModelState.IsValid) { return(Json(null)); } else { var ActionSetting = UnitOfWork.ActionSettingBL.GetByID(model.Id); if (ActionSetting != null) { ActionSetting.ReservationStatusId = model.ReservationStatusId; ActionSetting.ActionStepId = model.ActionStepId; ActionSetting.BranchId = model.BranchId; ActionSetting.RateSegmentCategoryId = model.RateSegmentCategoryId; ActionSetting.WeekDayId = model.WeekDayId; if (model.IsEnable == null || model.IsEnable == true) { ActionSetting.IsEnable = true; } else { ActionSetting.IsEnable = false; } UnitOfWork.ActionSettingBL.Update(ActionSetting); if (UnitOfWork.Complete() > 0) { return(Json(new { success = true, Message = "Action setting updated successfully" })); } else { return(Json(new { success = false, Message = "Failed to update Action setting" })); } } else { return(Json(new { success = false, Message = "Notification setting not found" })); } } } catch (Exception e) { return(Json(new { success = false, Message = "An error occured , please try again later" })); } }