Exemple #1
0
        public async Task <IActionResult> GetTicket(int id)
        {
            var ticket = await _repo.GetTicket(id);

            var ticketToReturn = _mapper.Map <TicketsForDetailed>(ticket);

            return(Ok(ticketToReturn));
        }
Exemple #2
0
        public async Task <IActionResult> AddComment(CommentToCreateDto commentToCreate)
        {
            var commentForAdd = _mapper.Map <Comment>(commentToCreate);

            commentForAdd.Ticket = await _repo.GetTicket(commentToCreate.TicketId);

            commentForAdd.Commenter = await _repo.GetUser(commentToCreate.CommenterId, false);

            commentForAdd.Updated = commentToCreate.Created;

            _repo.Add(commentForAdd);

            if (await _repo.SaveAll())
            {
                return(Ok(commentForAdd));
            }

            throw new Exception("Commect is not posted");
        }