public int UpdateLang(IdentityPropertyLang identity) { //Common syntax var sqlCmd = @"Property_Lang_Update"; var newId = 0; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@Name", identity.Name }, { "@LangCode", identity.LangCode } }; try { using (var conn = new SqlConnection(_connectionString)) { var returnObj = MsSqlHelper.ExecuteScalar(conn, CommandType.StoredProcedure, sqlCmd, parameters); newId = Convert.ToInt32(returnObj); } } catch (Exception ex) { var strError = "Failed to execute Property_Lang_Update. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
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 IdentityProperty GetDetail(int Id) { var info = new IdentityProperty(); var sqlCmd = @"Property_GetDetail"; var parameters = new Dictionary <string, object> { { "@Id", Id } }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters)) { //Get base info if (reader.Read()) { info = ExtractPropertyData(reader); } //Get data for all languages if (reader.NextResult()) { while (reader.Read()) { var langItem = new IdentityPropertyLang(); langItem.Id = Utils.ConvertToInt32(reader["Id"]); langItem.LangCode = reader["LangCode"].ToString(); langItem.Name = reader["Name"].ToString(); langItem.PropertyId = Utils.ConvertToInt32(reader["PropertyId"]); info.LangList.Add(langItem); } } } } } catch (Exception ex) { var strError = "Failed to execute Property_GetDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public List <IdentityPropertyLang> GetLangDetail(int Id) { List <IdentityPropertyLang> listItem = new List <IdentityPropertyLang>(); var sqlCmd = @"Property_Lang_GetDetail"; var parameters = new Dictionary <string, object> { { "@Id", Id } }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters)) { while (reader.Read()) { var info = new IdentityPropertyLang(); info.Id = Utils.ConvertToInt32(reader["Id"]); info.LangCode = reader["LangCode"].ToString(); info.Name = reader["Name"].ToString(); info.PropertyId = Utils.ConvertToInt32(reader["PropertyId"]); listItem.Add(info); } } } } catch (Exception ex) { var strError = "Failed to execute Property_GetLangDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(listItem); }
public int UpdateLang(IdentityPropertyLang identity) { return(myRepository.UpdateLang(identity)); }
public int InsertLang(IdentityPropertyLang identity) { return(myRepository.InsertLang(identity)); }