public County MapAndSaveCountyModelDCToCounty(County a, CountyModelDC b) { a.CountyId = b.countyId; a.CountyName = b.countyName; a.StateId = b.stateId; return(a); }
public CountyModelDC MapAndSaveCountyToCountyModelDC(CountyModelDC a, County b) { a.countyId = b.CountyId; a.countyName = b.CountyName; a.stateId = b.StateId; return(a); }
public void UpdateCounty(int id, CountyModelDC obj) { if (id < 0) { throw new ArgumentException(Messages.CountyExceptionUpdateById); } this._counties.UpdateCounty(id, obj); }
public County MapToCounty(CountyModelDC a) { return(new County() { CountyId = a.countyId, CountyName = a.countyName, StateId = a.stateId }); }
public void AddCounty(CountyModelDC obj) { if (obj == null) { throw new ArgumentOutOfRangeException(Messages.CountyExceptionAdd); } _db.Counties.Add(MapToCounty(obj)); _db.SaveChanges(); }
public void AddCounty(CountyModelDC obj) { foreach (CountyModelDC county in _counties.GetCounties()) { if (county.countyId == obj.countyId) { throw new ArgumentException(Messages.CountyExceptionAdd); } } this._counties.AddCounty(obj); }
public void UpdateCounty(int id, CountyModelDC obj) { if (id < 0) { throw new ArgumentOutOfRangeException(Messages.CountyExceptionUpdateById); } var county = _db.Counties.FirstOrDefault(x => x.CountyId == id); if (county == null) { throw new NullReferenceException(Messages.CountyExceptionUpdateById); } county = MapAndSaveCountyModelDCToCounty(county, obj); _db.SaveChanges(); }
// PUT: api/County/5 public void Put(int id, [FromBody] CountyModelDC county) { countyMethods.UpdateCounty(id, county); }
// POST: api/County public void Post([FromBody] CountyModelDC county) { countyMethods.AddCounty(county); }