public async Task <ActionResult <IEnumerable <PlaceProvider> > > IssueProformaInvoice( [FromForm] string placeProviderId, [FromForm] string slaLevel, [FromForm] DateTimeOffset slaFrom, [FromForm] DateTimeOffset slaUntil, [FromForm] int registrations, [FromForm] string currency ) { try { if (!slaLevel.ValidateSLA()) { throw new Exception("Invalid SLA Level"); } if (!currency.ValidateCurrency()) { throw new Exception("Invalid currency"); } if (registrations < 0) { throw new Exception("Invalid registrations"); } if (!User.IsAuthorizedToIssueInvoice(userRepository, placeProviderRepository, placeProviderId)) { throw new Exception("You are not authorized to issue invoices for this company. Please contact administrator or accountant."); } return(Ok(placeProviderRepository.IssueProformaInvoice(placeProviderId, slaLevel, registrations, currency, slaFrom, slaUntil))); } catch (ArgumentException exc) { logger.LogError(exc.Message); return(BadRequest(new ProblemDetails() { Detail = exc.Message })); } catch (Exception exc) { logger.LogError(exc, exc.Message); return(BadRequest(new ProblemDetails() { Detail = exc.Message })); } }