Exemple #1
0
        public ActionResult Delete(int id, TicketCategoryMvcViewModel model)
        {
            var result = _ticketService.DeleteCategory(id);

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

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public ActionResult Create(TicketCategoryMvcViewModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View(model));
            }

            var result = _ticketService.SaveCategory(Mapper.Map <TicketCategoryDto>(model));

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

            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public ActionResult Edit(int id, TicketCategoryMvcViewModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View(model));
            }

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

            var result = _ticketService.SaveCategory(Mapper.Map <TicketCategoryDto>(model));

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

            return(RedirectToAction("Index"));
        }