public IHttpActionResult VisualizeByFormat([FromUri] Guid document_id) { if (IsTokenValid() && authenticationService.IsAllowedToVisualizeDocument(GetTokenUserEmail(), document_id)) { try { string formatName = Request.Headers.GetValues("Format-Name").FirstOrDefault(); Document document = documentManagementService.GetById(document_id); Format format = formatManagementService.GetByName(formatName); return(Ok(codeGenerator.GenerateHTML(document, format))); } catch (MissingDocumentException e) { return(BadRequest(e.Message)); } catch (MissingFormatException e) { return(BadRequest(e.Message)); } catch (Exceptions e) { return(BadRequest(e.Message)); } } return(Unauthorized()); }
public IHttpActionResult GetByName([FromUri] string format_name) { if (IsTokenValid() && authenticationService.IsAllowedToGetFormats(GetTokenUserEmail())) { try { return(Ok(GetFormat.ToModel(formatManagementService.GetByName(format_name)))); } catch (MissingFormatException e) { return(BadRequest(e.Message)); } catch (Exceptions e) { return(BadRequest(e.Message)); } } return(Unauthorized()); }