Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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 }));
        }
Example #4
0
        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 }));
        }
Example #5
0
 public async Task <bool> UpdateAsync(CountryModifyRequest request)
 {
     return(await _countryRepository.UpdateAsync(request));
 }
Example #6
0
 public async Task <int> CreateAsync(CountryModifyRequest request)
 {
     return(await _countryRepository.CreateAsync(request));
 }