Example #1
0
        public ActionResult Edit(EditCommentSpecification spec)
        {
            var request  = mapper.Map <EditCommentRequest>(spec);
            var response = commentEditor.Value.Edit(request);

            if (response.CommentDoesNotExist)
            {
                return(HttpNotFound());
            }

            TempData.Clear();

            if (response.IsSuccess)
            {
                var comment = commentReader.Value.Read(spec.CommentId);
                return(RedirectToAction(nameof(TicketController.Index),
                                        this.GetName <TicketController>(),
                                        new { id = comment.Ticket.GetTicketReference() }));
            }

            var responseModel = mapper.Map <Models.Tickets.EditCommentResponse>(response);

            TempData.Add(EditCommentResponseKey, responseModel);
            TempData.Add(EditCommentSpecKey, spec);

            return(RedirectToAction(nameof(Edit), new { id = spec.CommentId?.Value }));
        }
Example #2
0
        public Models.Tickets.EditCommentResponse Post(EditCommentSpecification spec)
        {
            if (spec == null)
            {
                throw new ArgumentNullException(nameof(spec));
            }

            var request  = mapper.Map <EditCommentRequest>(spec);
            var response = commentEditor.Value.Edit(request);

            if (response.CommentDoesNotExist)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(mapper.Map <Models.Tickets.EditCommentResponse>(response));
        }