public int UpdateLang(IdentityPriceTypeLang identity) { //Common syntax var sqlCmd = @"M_PriceType_UpdateLang"; var newId = 0; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@Name", identity.Name }, { "@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_PriceType_UpdateLang. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
public ActionResult UpdateLang(PriceTypeLangModel 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 IdentityPriceTypeLang(); data.PriceTypeId = model.PriceTypeId; data.Id = model.Id; data.LangCode = model.LangCode; data.Name = model.Name; data.Description = model.Description; 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 IdentityPriceType GetDetail(int Id) { var info = new IdentityPriceType(); var sqlCmd = @"M_PriceType_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 = ExtractPriceTypeData(reader); } //Get data for all languages if (reader.NextResult()) { while (reader.Read()) { var langItem = new IdentityPriceTypeLang(); langItem.Id = Utils.ConvertToInt32(reader["Id"]); langItem.LangCode = reader["LangCode"].ToString(); langItem.Name = reader["Name"].ToString(); langItem.PriceTypeId = Utils.ConvertToInt32(reader["PriceTypeId"]); info.LangList.Add(langItem); } } } } } catch (Exception ex) { var strError = "Failed to execute M_PriceType_GetDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public IdentityPriceTypeLang GetLangDetail(int Id) { IdentityPriceTypeLang info = null; var sqlCmd = @"M_PriceType_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 IdentityPriceTypeLang(); info.Id = Utils.ConvertToInt32(reader["Id"]); info.LangCode = reader["LangCode"].ToString(); info.Name = reader["Name"].ToString(); info.PriceTypeId = Utils.ConvertToInt32(reader["PriceTypeId"]); info.Description = reader["Description"].ToString(); } } } } catch (Exception ex) { var strError = "Failed to execute M_PriceType_GetLangDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public int UpdateLang(IdentityPriceTypeLang identity) { return(myRepository.UpdateLang(identity)); }
public int AddNewLang(IdentityPriceTypeLang identity) { return(myRepository.AddNewLang(identity)); }