public JsonResult UpdateEmailSetting(EmailSettingVM model) { try { if (!ModelState.IsValid) { return(Json(null)); } else { var EmailSetting = UnitOfWork.EmailSettingBL.GetByID(model.Id); if (EmailSetting != null) { EmailSetting.ReseravationStatus = model.ReservationStatus; EmailSetting.EmailText = model.EmailText; UnitOfWork.EmailSettingBL.Update(EmailSetting); if (UnitOfWork.Complete() > 0) { return(Json(new { success = true, Message = "Email Setting updated successfully" })); } else { return(Json(new { success = false, Message = "Failed to update email Setting" })); } } else { return(Json(new { success = false, Message = "Banch not found" })); } } } catch (Exception e) { return(Json(new { success = false, Message = "An error occured , please try again later" })); } }
public JsonResult CreateEmailSetting(EmailSettingVM model) { try { if (!ModelState.IsValid) { return(Json(null)); } else { var sameEmailSettingExist = UnitOfWork.EmailSettingBL.CheckExist(b => b.ReseravationStatus == model.ReservationStatus); if (sameEmailSettingExist) { return(Json(new { success = false, Message = "Email setting already exists" })); } var EmailSetting = new EmailSetting { ReseravationStatus = model.ReservationStatus, EmailText = model.EmailText }; UnitOfWork.EmailSettingBL.Add(EmailSetting); if (UnitOfWork.Complete() > 0) { return(Json(new { success = true, Message = "Email setting added successfully" })); } else { return(Json(new { success = false, Message = "Failed to add email setting" })); } } } catch (Exception e) { return(Json(new { success = false, Message = "An error occured , please try again later" })); } }