Exemplo n.º 1
0
        public virtual ActionResult CreateResolution(CreateEditResolutionModel viewData)
        {
            if (_ticketRepo.GetResolutionByName(viewData.Name) != null)
            {
                ModelState.AddModelError("Name", "This value already exists.");
            }

            if (ModelState.IsValid)
            {
                Mapper.CreateMap<CreateEditResolutionModel, TicketResolution>();
                TicketResolution resolution = Mapper.Map(viewData, new TicketResolution());

                _ticketRepo.Save(resolution);

                return RedirectToAction(MVC.Admin.Attribute.CreateResolution());
            }

            viewData.Resolutions = _ticketRepo.GetResolutions();

            return View(viewData);
        }
Exemplo n.º 2
0
        public virtual ActionResult EditResolution(int resolutionId, CreateEditResolutionModel viewData)
        {
            TicketResolution resolution = _ticketRepo.GetResolutionById(resolutionId);
            if (resolution == null)
            {
                return PermanentRedirectToAction(MVC.Error.InvalidAction());
            }

            TicketResolution existingResolution = _ticketRepo.GetResolutionByName(viewData.Name);
            if (existingResolution != null && existingResolution.Id != resolutionId)
            {
                ModelState.AddModelError("Name", "This value already exists.");
            }

            if (ModelState.IsValid)
            {
                Mapper.CreateMap<CreateEditResolutionModel, TicketResolution>();
                Mapper.Map(viewData, resolution);
                _ticketRepo.Save(resolution);

                return RedirectToAction(MVC.Admin.Attribute.CreateResolution());
            }

            return View(viewData);
        }