Beispiel #1
0
        public IActionResult Post([FromBody] UseTicketApiModel useTicket)
        {
            try
            {
                UseTicket newTicket = useTicket.ToDomainModel();
                newTicket = _useTicketService.Add(newTicket);

                return(Ok(newTicket.ToApiModel()));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("CreatUseTicketError", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Beispiel #2
0
        public IActionResult Put(int id, [FromBody] UseTicketApiModel useTicket)
        {
            try
            {
                UseTicket updatedTicket = useTicket.ToDomainModel();
                updatedTicket.Id = id;

                updatedTicket = _useTicketService.Update(updatedTicket);
                return(Ok(updatedTicket.ToApiModel()));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("UpdateUseTicketError", ex.Message);
                return(BadRequest(ModelState));
            }
        }