public async Task InsertADMasterCity(ADMasterCity objADMasterCity) { try { _Context.ADMasterCities.Add(objADMasterCity); await _Context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task UpdateADMasterCity(ADMasterCity objADMasterCity) { try { _Context.Entry(objADMasterCity).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await _Context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <ActionResult <MasterCityResult> > PostADMasterCity(ADMasterCity objADMasterCity) { try { await _IMasterCityInterface.InsertADMasterCity(objADMasterCity); return(CreatedAtAction("GetADMasterCity", new { id = objADMasterCity.MasterCityId }, objADMasterCity)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task DeleteADMasterCity(long MasterCityId) { try { ADMasterCity objADMasterCity = _Context.ADMasterCities.Find(MasterCityId); _Context.ADMasterCities.Remove(objADMasterCity); await _Context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <ActionResult <MasterCityResult> > PutADMasterCity(long id, ADMasterCity objADMasterCity) { if (id != objADMasterCity.MasterCityId) { return(BadRequest()); } try { await _IMasterCityInterface.UpdateADMasterCity(objADMasterCity); return(_IMasterCityInterface.GetADMasterCityByID(id)); } catch (DbUpdateConcurrencyException) { if (!_IMasterCityInterface.ADMasterCityExists(id)) { return(NotFound()); } else { throw; } } catch (Exception ex) { throw new Exception(ex.Message); } return(NoContent()); }