public async Task <IActionResult> UpdateTicket([FromRoute] int id, [FromBody] TicketForm ticketForm) { var ticketItem = await _repository.GetTicketById(id); if (ticketItem == null) { return(NotFound()); } _mapper.Map(ticketForm, ticketItem); //Real Update _repository.UpdateTicket(ticketItem); // Not Necessary return(NoContent()); }
public Ticket CloseTicket(Ticket ticket) { var currentTicket = GetTicketById(ticket.Id); if (currentTicket == null) { throw new Exception("Ticket not found"); } if (currentTicket.ClosedAt != null) { throw new Exception("Ticket Already Closed"); } currentTicket.ClosedAt = ticket.ClosedAt ?? DateTimeOffset.Now; _ticketRepo.UpdateTicket(currentTicket); return(currentTicket); }