public bool District_Update(IdentityDistrict identity) { //Common syntax var sqlCmd = @"District_Update"; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@Name", identity.Name }, { "@Code", identity.Code }, { "@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 District_Update. Error: " + ex.Message; throw new CustomSQLException(strError); } return(true); }
public IdentityDistrict District_GetById(int Id) { var info = new IdentityDistrict(); var sqlCmd = @"District_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 = ExtractDistrictData(reader); } } } } catch (Exception ex) { var strError = "Failed to execute District_GetById. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
private IdentityDistrict ExtractDistrictData(IDataReader reader) { var record = new IdentityDistrict(); //Seperate properties record.Id = Utils.ConvertToInt32(reader["Id"]); record.Name = reader["Name"].ToString(); record.Code = reader["Code"].ToString(); record.Status = Utils.ConvertToInt32(reader["Status"]); return(record); }
public bool District_Update(IdentityDistrict identity) { return(myRepository.District_Update(identity)); }
public bool District_Insert(IdentityDistrict identity) { return(myRepository.District_Insert(identity)); }