Esempio n. 1
0
        public async Task <IActionResult> Edit(string id, [FromForm] DappUpdateModel updateModel)
        {
            if (ModelState.IsValid)
            {
                var isEffected = await _dappService.UpdateAsync(id, updateModel);

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

            return(View(updateModel));
        }
Esempio n. 2
0
        public async Task <bool> UpdateAsync(string id, DappUpdateModel updateModel)
        {
            int effected = 0;

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

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

                _unitOfWork.DappRepository.Update(entity);

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

            return(effected > 0);
        }