public async Task <bool> UpdateCountry(CountryDVM Country) { bool result = false; if (Country != null) { Country c = await countryRepository.GetAsync(Country.Code); if (c != null) { c.Name = Country.Name; try { await countryRepository.UpdateAsync(c); result = true; } catch (Exception ex) { throw ex; } } } return(result); }
public async Task <CountryDVM> GetCountryByID(object Id) { CountryDVM cdvm = new CountryDVM(); if (Id != null) { Country c = await countryRepository.GetAsync(Id); if (c != null) { cdvm = mapper.Map <CountryDVM>(c); } } return(cdvm); }
public async Task <bool> AddCountry(CountryDVM Country) { bool id = false; if (Country != null) { Country c = mapper.Map <Country>(Country); try { var obj = await countryRepository.InsertAsync(c); id = true; } catch (Exception ex) { throw ex; } } return(id); }
public async Task <CountryDVM> GetCountryByIDAsync(object Id) { try { CountryDVM cdvm = null; if (Id != null) { Country d = await countryRepository.GetAsync(Id); if (d != null) { cdvm = mapper.Map <CountryDVM>(d); } } return(cdvm); } catch (Exception e) { throw e; } }
public async Task <bool> UpdateCountryAsync(CountryDVM entity) { bool result = false; if (entity != null) { Country d = countryRepository.Get(entity.Code); if (d != null) { d.Name = entity.Name; try { await countryRepository.UpdateAsync(d); result = true; } catch (Exception ex) { throw ex; } } } return(result); }