public async Task <bool> UpdateAsync(CountryModifyRequest request) { await _countryRepository.Get(x => x.Id == request.Id) .Set(x => x.Code, request.Code) .Set(x => x.Name, request.Name) .UpdateAsync(); return(true); }
public async Task <int> CreateAsync(CountryModifyRequest request) { var country = new Country() { Code = request.Code, Name = request.Name }; var id = await _countryRepository.AddWithInt32EntityAsync(country); return(id); }
public async Task <IActionResult> Create(CountryModel model) { var country = new CountryModifyRequest() { Id = model.Id, Name = model.Name, Code = model.Code }; var exist = _countryService.FindByName(model.Name); if (exist != null) { return(RedirectToErrorPage()); } var id = await _countryService.CreateAsync(country); return(RedirectToAction(nameof(Detail), new { id })); }
public IActionResult Update(CountryModel model) { if (model.Id <= 0) { return(RedirectToErrorPage()); } var exist = _countryService.Find(model.Id); if (exist == null) { return(RedirectToErrorPage()); } var country = new CountryModifyRequest() { Id = model.Id, Name = model.Name, Code = model.Code }; _countryService.UpdateAsync(country); return(RedirectToAction(nameof(Detail), new { id = country.Id })); }
public async Task <bool> UpdateAsync(CountryModifyRequest request) { return(await _countryRepository.UpdateAsync(request)); }
public async Task <int> CreateAsync(CountryModifyRequest request) { return(await _countryRepository.CreateAsync(request)); }