예제 #1
0
        public ActionResult Edit(CrudSalesOrderDto salesOrder, IUpdateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                service.ResetDto(salesOrder);
                return(View(salesOrder));
            }

            var response = service.Update(salesOrder);

            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, salesOrder);
            return(View(salesOrder));
        }
        public ActionResult Edit(CrudSalesOrderDto salesOrder, IUpdateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                service.ResetDto(salesOrder);
                return View(salesOrder);
            }

            var response = service.Update(salesOrder);
            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, salesOrder);
            return View(salesOrder);
        }