Esempio n. 1
0
        public async Task <IActionResult> Delete(long ticketTypeId)
        {
            var currentUser = await _identityService.GetCurrentUser();

            if (currentUser == null)
            {
                return(BadRequest(new { error = "You are not allowed!" }));
            }

            var person = await _identityService.GetPersonByUserId(currentUser.Id);

            if (person == null)
            {
                return(BadRequest(new { error = "Person was not found" }));
            }

            var ticketType = await _ticketTypeService.GetTicketTypeById(ticketTypeId);

            if (ticketType == null)
            {
                return(BadRequest(new { error = "Selected ticketType was not found" }));
            }

            var anyTickets = await _ticketService.AnyTicketsOnTypeId(ticketTypeId);

            if (anyTickets)
            {
                return(BadRequest(new { error = "You first must delete tickets associated with this ticket type" }));
            }

            await _ticketTypeService.DeleteTicketType(ticketType);

            return(NoContent());
        }
        public ActionResult DeleteTicketType(int Id)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest("Invalid Request");
            //}

            var updateResult = _ticketTypeService.DeleteTicketType(Id);

            if (!string.IsNullOrEmpty(updateResult))
            {
                return(StatusCode((int)HttpStatusCode.NotAcceptable, updateResult));
            }
            return(Ok());
        }