public async Task <ActionResult <MasterCountryResult> > PostADMasterCountry(ADMasterCountry objADMasterCountry) { try { await _IMasterCountryInterface.InsertADMasterCountry(objADMasterCountry); return(CreatedAtAction("GetADMasterCountry", new { id = objADMasterCountry.MasterCountryId }, objADMasterCountry)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task InsertADMasterCountry(ADMasterCountry objADMasterCountry) { try { _Context.ADMasterCountries.Add(objADMasterCountry); await _Context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task UpdateADMasterCountry(ADMasterCountry objADMasterCountry) { try { _Context.Entry(objADMasterCountry).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await _Context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task DeleteADMasterCountry(long MasterCountryId) { try { ADMasterCountry objADMasterCountry = _Context.ADMasterCountries.Find(MasterCountryId); _Context.ADMasterCountries.Remove(objADMasterCountry); await _Context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <ActionResult <MasterCountryResult> > PutADMasterCountry(long id, ADMasterCountry objADMasterCountry) { if (id != objADMasterCountry.MasterCountryId) { return(BadRequest()); } try { await _IMasterCountryInterface.UpdateADMasterCountry(objADMasterCountry); return(_IMasterCountryInterface.GetADMasterCountryByID(id)); } catch (DbUpdateConcurrencyException) { if (!_IMasterCountryInterface.ADMasterCountryExists(id)) { return(NotFound()); } else { throw; } } catch (Exception ex) { throw new Exception(ex.Message); } return(NoContent()); }