public ActionResult UpdateLang(GroupPropertyLangModel model) { var msg = ManagerResource.LB_OPERATION_SUCCESS; var isSuccess = false; if (!ModelState.IsValid) { string messages = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage + x.Exception)); this.AddNotification(messages, NotificationType.ERROR); return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = messages })); } try { var code = 0; //Begin db transaction var data = new IdentityGroupPropertyLang(); data.GroupId = model.GroupId; data.Id = model.Id; data.Description = model.Description; data.GroupName = model.Name; data.LangCode = model.LangCode; if (model.Id > 0) { //Update _mainStore.UpdateLang(data); } else { //Add new code = _mainStore.AddNewLang(data); if (code == EnumCommonCode.Error) { return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = ManagerResource.LB_DUPLICATE_DATA, clientcallback = " location.reload()" })); } } isSuccess = true; } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed for UpdateLang request: " + ex.ToString()); return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = NotifSettings.Error_SystemBusy })); } return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = msg, clientcallback = " location.reload()" })); }
public ActionResult UpdateLang() { GroupPropertyLangModel model = new GroupPropertyLangModel(); var id = Utils.ConvertToInt32(Request["Id"]); var groupId = Utils.ConvertToInt32(Request["GroupId"]); if (groupId == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (id > 0) { model.IsUpdate = true; } try { model.GroupId = groupId; //Begin db transaction var listLangExists = _mainStore.GetLangDetail(groupId); if (id == 0) { var listItem = new List <string>(); if (listLangExists != null && listLangExists.Count > 0) { listItem.AddRange(listLangExists.Select(s => s.LangCode)); } model.Languages = CommonHelpers.GetListLanguageNotExist(listItem); } else { model.Languages = CommonHelpers.GetListLanguages(); var info = listLangExists.FirstOrDefault(s => s.Id == id); if (info != null) { model.GroupId = groupId; model.Id = info.Id; model.LangCode = info.LangCode; model.Name = info.GroupName; model.Description = info.Description; } } } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed for Show UpdateLang frm request: " + ex.ToString()); } return(PartialView("../GroupProperty/_UpdateLang", model)); }