public async Task <ActionResult <TicketType_TicketTypeDTO> > Create([FromBody] TicketType_TicketTypeDTO TicketType_TicketTypeDTO) { if (!ModelState.IsValid) { throw new BindException(ModelState); } if (!await HasPermission(TicketType_TicketTypeDTO.Id)) { return(Forbid()); } TicketType TicketType = ConvertDTOToEntity(TicketType_TicketTypeDTO); TicketType = await TicketTypeService.Create(TicketType); TicketType_TicketTypeDTO = new TicketType_TicketTypeDTO(TicketType); if (TicketType.IsValidated) { return(TicketType_TicketTypeDTO); } else { return(BadRequest(TicketType_TicketTypeDTO)); } }
public IActionResult Create(TicketTypeDto ticketTypeDto) { logger.Info(nameof(TicketTypeController.Create)); if (!ModelState.IsValid) { return(View(ticketTypeDto)); } try { ticketTypeService.Create(ticketTypeDto); } catch (Exception exception) { logger.Error(exception); return(BadRequest()); } return(RedirectToAction(nameof(Index))); }