public IHttpActionResult PurchaseTicket([FromBody] Flight flight) { List <Ticket> ticketLst = null; bool isAuthorized = false; Action act = () => { isAuthorized = GetInternalLoginTokenInternal <Customer>(out LoginToken <Customer> loginTokenCustomer); if (isAuthorized) { ticketLst = _loggedInCustomerFacade.PurchaseTickets(loginTokenCustomer, flight); } }; ProcessExceptions(act); if (!isAuthorized) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, $"Sorry, but you're not a customer. Ypur accsess is denied."))); } if (ticketLst == null) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, $"There is no tickets for the flight with the ID {flight.ID} in the system."))); } return(Ok(ticketLst)); }