public ActionResult UpdateLang(PropertyLangModel 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 IdentityPropertyLang(); data.PropertyId = model.PropertyId; data.Id = model.Id; data.Name = model.Name; data.LangCode = model.LangCode; if (model.Id > 0) { //Update _mainStore.UpdateLang(data); } else { //Add new code = _mainStore.InsertLang(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() { PropertyLangModel model = new PropertyLangModel(); var id = Utils.ConvertToInt32(Request["Id"]); var propertyId = Utils.ConvertToInt32(Request["PropertyId"]); if (propertyId == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (id > 0) { model.IsUpdate = true; } try { model.PropertyId = propertyId; //Begin db transaction var listLangExists = _mainStore.GetLangDetail(propertyId); 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.PropertyId = propertyId; model.Id = info.Id; model.LangCode = info.LangCode; model.Name = info.Name; } } } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed for Show UpdateLang frm request: " + ex.ToString()); } return(PartialView("../Property/_UpdateLang", model)); }