public IdentityPriceType GetById(int Id) { var info = new IdentityPriceType(); var sqlCmd = @"PriceType_GetById"; 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()) { info = ExtractPriceTypeData(reader); } } } } catch (Exception ex) { var strError = "Failed to execute PriceType_GetPriceTypeById. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public int Insert(IdentityPriceType identity) { var newId = 0; var sqlCmd = @"M_PriceType_Insert"; var parameters = new Dictionary <string, object> { { "@Code", identity.Code }, { "@Name", identity.Name }, { "@Icon", identity.Icon }, { "@Status", identity.Status }, { "@CreatedBy", identity.CreatedBy }, { "@Description", identity.Description } }; try { using (var conn = new SqlConnection(_connectionString)) { var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters); if (reader.Read()) { newId = Utils.ConvertToInt32(reader[0]); } } } catch (Exception ex) { var strError = "Failed to M_PriceType_Insert. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
public bool Update(IdentityPriceType identity) { //Common syntax var sqlCmd = @"M_PriceType_Update"; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@Name", identity.Name }, { "@Code", identity.Code }, { "@Icon", identity.Icon }, { "@Status", identity.Status }, { "@Description", identity.Description } }; try { using (var conn = new SqlConnection(_connectionString)) { MsSqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, sqlCmd, parameters); } } catch (Exception ex) { var strError = "Failed to execute M_PriceType_Update. Error: " + ex.Message; throw new CustomSQLException(strError); } return(true); }
private IdentityPriceType ExtractEditFormData(PriceTypeEditModel formData) { var myIdetity = new IdentityPriceType(); myIdetity.Id = formData.Id; myIdetity.Name = formData.Name; myIdetity.Code = formData.Code; myIdetity.Icon = formData.Icon; myIdetity.Status = formData.Status; myIdetity.Description = formData.Description; return(myIdetity); }
private PriceTypeEditModel RenderEditModel(IdentityPriceType identity) { var editModel = new PriceTypeEditModel(); editModel.Id = identity.Id; editModel.Name = identity.Name; editModel.Code = identity.Code; editModel.Icon = identity.Icon; editModel.Status = identity.Status; editModel.LangList = identity.LangList; editModel.Description = identity.Description; return(editModel); }
private IdentityPriceType ExtractCreateFormData(PriceTypeCreateModel formData) { var myIdetity = new IdentityPriceType(); myIdetity.Name = formData.Name; myIdetity.Code = formData.Code; //myIdetity.UrlFriendly = UrlFriendly.ConvertToUrlFriendly(formData.Name); myIdetity.Icon = formData.Icon; myIdetity.Status = Utils.ConvertToInt32(formData.Status); myIdetity.CreatedBy = User.Identity.GetUserId(); myIdetity.Description = formData.Description; return(myIdetity); }
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 ActionResult Index(ManagePriceTypeModel model) { int currentPage = 1; int pageSize = SystemSettings.DefaultPageSize; if (string.IsNullOrEmpty(model.SearchExec)) { model.SearchExec = "Y"; if (!ModelState.IsValid) { ModelState.Clear(); } } if (Request["Page"] != null) { currentPage = Utils.ConvertToInt32(Request["Page"], 1); } var filter = new IdentityPriceType { Keyword = !string.IsNullOrEmpty(model.Keyword) ? model.Keyword.Trim() : null, Status = model.Status == null ? -1 : (int)model.Status }; try { model.SearchResults = _mainStore.GetAll(filter, currentPage, SystemSettings.DefaultPageSize); if (model.SearchResults != null && model.SearchResults.Count > 0) { model.TotalCount = model.SearchResults[0].TotalCount; model.CurrentPage = currentPage; model.PageSize = pageSize; } } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed to get data because: " + ex.ToString()); return(View(model)); } return(View(model)); }
private IdentityPriceType ExtractPriceTypeData(IDataReader reader) { var record = new IdentityPriceType(); //Seperate properties record.Id = Utils.ConvertToInt32(reader["Id"]); record.Name = reader["Name"].ToString(); record.Code = reader["Code"].ToString(); record.Icon = reader["Icon"].ToString(); record.Description = reader["Description"].ToString(); record.CreatedBy = reader["CreatedBy"].ToString(); record.CreatedDate = reader["CreatedDate"] == DBNull.Value ? null : (DateTime?)reader["CreatedDate"]; record.LastUpdated = reader["LastUpdated"] == DBNull.Value ? null : (DateTime?)reader["LastUpdated"]; record.LastUpdatedBy = reader["LastUpdatedBy"].ToString(); record.Status = Utils.ConvertToInt32(reader["Status"]); return(record); }
public List <IdentityPriceType> GetAll(IdentityPriceType filter, int currentPage, int pageSize) { //Common syntax var sqlCmd = @"M_PriceType_GetByPage"; List <IdentityPriceType> listData = null; //For paging int offset = (currentPage - 1) * pageSize; //For parameters var parameters = new Dictionary <string, object> { { "@Keyword", filter.Keyword }, { "@Status", filter.Status }, { "@Offset", offset }, { "@PageSize", pageSize }, }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters)) { listData = ParsingListPriceTypeFromReader(reader); } } } catch (Exception ex) { var strError = "Failed to execute M_PriceType_GetByPage. Error: " + ex.Message; throw new CustomSQLException(strError); } return(listData); }
public bool Update(IdentityPriceType identity) { return(myRepository.Update(identity)); }
public int Insert(IdentityPriceType identity) { return(myRepository.Insert(identity)); }
public List <IdentityPriceType> GetAll(IdentityPriceType filter, int currentPage, int pageSize) { return(myRepository.GetAll(filter, currentPage, pageSize)); }