Пример #1
0
        public async Task <IActionResult> Edit(string id, [FromForm] RankUpdateModel updateModel)
        {
            if (ModelState.IsValid)
            {
                var isEffected = await _rankService.UpdateAsync(id, updateModel);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(updateModel));
        }
Пример #2
0
        public async Task <bool> UpdateAsync(string id, RankUpdateModel updateModel)
        {
            int effected = 0;

            try
            {
                var source = await _unitOfWork.RankRepository.GetAsync(id);

                var entity = _mapper.Map(updateModel, source);

                _unitOfWork.RankRepository.Update(entity);

                effected = await _unitOfWork.SaveAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message, updateModel);
                throw;
            }

            return(effected > 0);
        }