Exemple #1
0
        public async Task <IActionResult> EditItem(EditItemVM editItemVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(editItemVM));
            }
            var dtoModel = mapper.Map <UpdateItemModel>(editItemVM);
            var result   = await itemsManager.UpdateAsync(dtoModel);

            if (!result.Succeed)
            {
                result.Errors.ToList().ForEach(e => ModelState.AddModelError("", e));
                return(View(editItemVM));
            }
            return(RedirectToAction(nameof(Store.Item), nameof(Store), new { id = dtoModel.ItemId }));
        }