Exemplo n.º 1
0
        public ActionResult Delete(int id, ServiceMvcViewModel model)
        {
            var result = _serviceService.Delete(id);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", $"Ошибки при удалении услуги:</br>"
                                         + $"{string.Join("</br>", result.Errors)}");
                return(View(model));
            }

            return(RedirectToAction("Index", new { orgId = model.OwnerId }));
        }
Exemplo n.º 2
0
        public ActionResult Create(ServiceMvcViewModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View(model));
            }

            var result = _serviceService.Save(Mapper.Map <ServiceDto>(model));

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", $"Ошибки при добавлении услуги:</br>"
                                         + $"{string.Join("</br>", result.Errors)}");
                return(View(model));
            }

            return(RedirectToAction("Index", new { orgId = model.OwnerId }));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id, ServiceMvcViewModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View(model));
            }

            if (model.Id == 0)
            {
                throw new HttpException((int)HttpStatusCode.InternalServerError,
                                        "Не указан идентификатор услуги");
            }

            var result = _serviceService.Save(Mapper.Map <ServiceDto>(model));

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", $"Ошибки при обновлении услуги:</br>"
                                         + $"{string.Join("</br>", result.Errors)}");
                return(View(model));
            }

            return(RedirectToAction("Index", new { orgId = model.OwnerId }));
        }