public int UpdateLang(IdentityPlaceTypeGroupLang identity) { //Common syntax var sqlCmd = @"M_PlaceTypeGroup_UpdateLang"; var newId = 0; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@GroupName", identity.GroupName }, { "@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 M_PlaceTypeGroup_UpdateLang. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
public IdentityPlaceTypeGroupLang GetLangDetail(int Id) { IdentityPlaceTypeGroupLang info = null; var sqlCmd = @"M_PlaceTypeGroup_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)) { if (reader.Read()) { info = new IdentityPlaceTypeGroupLang(); info.Id = Utils.ConvertToInt32(reader["Id"]); info.LangCode = reader["LangCode"].ToString(); info.GroupName = reader["GroupName"].ToString(); info.GroupId = Utils.ConvertToInt32(reader["GroupId"]); } } } } catch (Exception ex) { var strError = "Failed to execute M_PlaceTypeGroup_GetLangDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public ActionResult UpdateLang(PlaceTypeGroupLangModel 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 IdentityPlaceTypeGroupLang(); data.GroupId = model.GroupId; data.Id = model.Id; data.LangCode = model.LangCode; data.GroupName = model.Name; 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 IdentityPlaceTypeGroup GetDetail(int Id) { var info = new IdentityPlaceTypeGroup(); var sqlCmd = @"M_PlaceTypeGroup_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 = ExtractPlaceTypeGroupData(reader); } //Get data for all languages if (reader.NextResult()) { while (reader.Read()) { var langItem = new IdentityPlaceTypeGroupLang(); langItem.Id = Utils.ConvertToInt32(reader["Id"]); langItem.LangCode = reader["LangCode"].ToString(); langItem.GroupName = reader["GroupName"].ToString(); langItem.GroupId = Utils.ConvertToInt32(reader["GroupId"]); info.LangList.Add(langItem); } } } } } catch (Exception ex) { var strError = "Failed to execute M_PlaceTypeGroup_GetDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }