public IdentityCurrency GetById(int Id) { var info = new IdentityCurrency(); var sqlCmd = @"Currency_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 = ExtractCurrencyData(reader); } } } } catch (Exception ex) { var strError = "Failed to execute Currency_GetById. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public int Insert(IdentityCurrency identity) { //Common syntax var sqlCmd = @"Currency_Insert"; var newId = 0; //For parameters var parameters = new Dictionary <string, object> { { "@Name", identity.Name }, { "@Code", identity.Code }, //{"@CreatedBy", identity.CreatedBy}, { "@Status", identity.Status } }; 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 Currency_Insert. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
public bool Update(IdentityCurrency identity) { //Common syntax var sqlCmd = @"Currency_Update"; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@Name", identity.Name }, { "@Code", identity.Code }, //{"@LastUpdatedBy", identity.LastUpdatedBy}, { "@Status", identity.Status } }; try { using (var conn = new SqlConnection(_connectionString)) { MsSqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, sqlCmd, parameters); } } catch (Exception ex) { var strError = "Failed to execute Currency_Update. Error: " + ex.Message; throw new CustomSQLException(strError); } return(true); }
private IdentityCurrency ExtractCreateFormData(CurrencyCreateModel formData) { var myIdetity = new IdentityCurrency(); myIdetity.Name = formData.Name; myIdetity.Code = formData.Code; myIdetity.Status = formData.Status; return(myIdetity); }
private CurrencyEditModel RenderEditModel(IdentityCurrency identity) { var editModel = new CurrencyEditModel(); editModel.Id = identity.Id; editModel.Name = identity.Name; editModel.Code = identity.Code; editModel.Status = identity.Status; return(editModel); }
private IdentityCurrency ExtractEditFormData(CurrencyEditModel formData) { var myIdetity = new IdentityCurrency(); myIdetity.Id = formData.Id; myIdetity.Name = formData.Name; myIdetity.Code = formData.Code; myIdetity.Status = formData.Status; return(myIdetity); }
private IdentityCurrency ExtractCurrencyData(IDataReader reader) { var record = new IdentityCurrency(); //Seperate properties record.Id = Utils.ConvertToInt32(reader["Id"]); record.Name = reader["Name"].ToString(); record.Code = reader["Code"].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 ActionResult Index(ManageCurrencyModel 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 IdentityCurrency { Keyword = !string.IsNullOrEmpty(model.Keyword) ? model.Keyword.Trim() : null, Status = model.Status == null ? -1 : (int)model.Status }; try { model.SearchResults = _mainStore.GetByPage(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)); }
public List <IdentityCurrency> GetByPage(IdentityCurrency filter, int currentPage, int pageSize) { //Common syntax var sqlCmd = @"Currency_GetByPage"; List <IdentityCurrency> 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 = ParsingListCurrencyFromReader(reader); } } } catch (Exception ex) { var strError = "Failed to execute Currency_GetByPage. Error: " + ex.Message; throw new CustomSQLException(strError); } return(listData); }
public bool Update(IdentityCurrency identity) { return(myRepository.Update(identity)); }
public int Insert(IdentityCurrency identity) { return(myRepository.Insert(identity)); }
public List <IdentityCurrency> GetByPage(IdentityCurrency filter, int currentPage, int pageSize) { return(myRepository.GetByPage(filter, currentPage, pageSize)); }