public async Task<ActionResult> Edit(Tag tag, IUpdateServiceAsync service)
        {
            if (!ModelState.IsValid)
                //model errors so return immediately
                return View(tag);

            var response = await service.UpdateAsync(tag);
            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage;
                return RedirectToAction("Index");
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, tag);
            return View(tag);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Edit(Tag tag, IUpdateServiceAsync service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                return(View(tag));
            }

            var response = await service.UpdateAsync(tag);

            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage;
                return(RedirectToAction("Index"));
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, tag);
            return(View(tag));
        }
Ejemplo n.º 3
0
 public UpdateController(IUpdateServiceAsync updateService)
 {
     _updateService = updateService.ThrowIfNull(nameof(updateService));
 }