Esempio n. 1
0
        public async Task <ActionResult <TicketType_TicketTypeDTO> > Delete([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.Delete(TicketType);

            TicketType_TicketTypeDTO = new TicketType_TicketTypeDTO(TicketType);
            if (TicketType.IsValidated)
            {
                return(TicketType_TicketTypeDTO);
            }
            else
            {
                return(BadRequest(TicketType_TicketTypeDTO));
            }
        }
        public IActionResult DeleteConfirmed(int id)
        {
            logger.Info(nameof(TicketTypeController.DeleteConfirmed));

            try
            {
                ticketTypeService.Delete(id);
            }
            catch (Exception exception)
            {
                logger.Error(exception);

                return(BadRequest());
            }

            return(RedirectToAction(nameof(Index)));
        }