public ActionResult EditSettings(GroupManageSettingModel model, SubmitTypeEnums submit) { if (ModelState.IsValid) { var response = _rotatingImageGroupServices.SaveGroupSettings(model); if (response.Success) { SetSuccessMessage(response.Message); switch (submit) { case SubmitTypeEnums.Save: return RedirectToAction("Index"); default: return RedirectToAction("EditSettings", new { id = model.Id }); } } SetErrorMessage(response.Message); } return View(model); }
/// <summary> /// Save group settings /// </summary> /// <param name="model">the group setting model</param> /// <returns></returns> public ResponseModel SaveGroupSettings(GroupManageSettingModel model) { var group = GetById(model.Id); if (group != null) { group.Settings = SerializeUtilities.SerializeObject(model.GroupSettingModel); var response = Update(group); return response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::UpdateSettingSuccessfully:::Update group settings successfully.") : _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::UpdateSettingFailure:::Update group settings failed. Please try again later.")); } return new ResponseModel { Success = false, Message = _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::ObjectNotFounded:::Rotating image group is not founded.") }; }
/// <summary> /// Get group rotating image manage model /// </summary> /// <param name="id">the group id</param> /// <returns></returns> public GroupManageSettingModel GetGroupManageSettingModel(int id) { var group = GetById(id); if (group != null) { var model = new GroupManageSettingModel { Id = id, GroupSettingModel = SerializeUtilities.DeserializeString<GroupSettingModel>(@group.Settings) }; return model; } return null; }