public int UpdateLang(IdentityGroupPropertyLang identity) { //Common syntax var sqlCmd = @"M_GroupProperty_UpdateLang"; var newId = 0; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@GroupName", identity.GroupName }, { "@LangCode", identity.LangCode }, { "@Description", identity.Description } }; 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 M_GroupProperty_UpdateLang. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
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 IdentityGroupProperty GetDetail(int Id) { var info = new IdentityGroupProperty(); var sqlCmd = @"M_GroupProperty_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 = ExtractGroupPropertyData(reader); } //Get data for all languages if (reader.NextResult()) { while (reader.Read()) { var langItem = new IdentityGroupPropertyLang(); langItem.Id = Utils.ConvertToInt32(reader["Id"]); langItem.LangCode = reader["LangCode"].ToString(); langItem.GroupName = reader["GroupName"].ToString(); langItem.Description = reader["Description"].ToString(); langItem.GroupId = Utils.ConvertToInt32(reader["GroupId"]); info.LangList.Add(langItem); } } } } } catch (Exception ex) { var strError = "Failed to execute M_GroupProperty_GetDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public List <IdentityGroupPropertyLang> GetLangDetail(int Id) { List <IdentityGroupPropertyLang> listItem = new List <IdentityGroupPropertyLang>(); var sqlCmd = @"M_GroupProperty_GetLangDetail"; 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 IdentityGroupPropertyLang(); info.Id = Utils.ConvertToInt32(reader["Id"]); info.LangCode = reader["LangCode"].ToString(); info.GroupName = reader["GroupName"].ToString(); info.Description = reader["Description"].ToString(); info.GroupId = Utils.ConvertToInt32(reader["GroupId"]); listItem.Add(info); } } } } catch (Exception ex) { var strError = "Failed to execute M_GroupProperty_GetLangDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(listItem); }
public int UpdateLang(IdentityGroupPropertyLang identity) { return(myRepository.UpdateLang(identity)); }
public int AddNewLang(IdentityGroupPropertyLang identity) { return(myRepository.AddNewLang(identity)); }