public IHttpActionResult GetDocumentsParagraphs([FromUri] Guid document_id) { if (IsTokenValid() && authenticationService.IsAllowedToGetDocument(GetTokenUserEmail(), document_id)) { try { return(Ok(BaseParagraph.ToModel(paragraphManagementService.GetAllByDocument(document_id)))); } catch (MissingDocumentException e) { return(BadRequest(e.Message)); } catch (Exceptions e) { return(BadRequest(e.Message)); } } return(Unauthorized()); }
public IHttpActionResult AddParagraphToDocument([FromUri] Guid document_id, [FromBody] AddParagraph paragraph) { if (IsTokenValid() && authenticationService.IsAllowedToUpdateDocument(GetTokenUserEmail(), document_id)) { try { Paragraph newParagraph = paragraphManagementService.Add(document_id, AddParagraph.ToEntity(paragraph)); BaseParagraph modelNewParagraph = BaseParagraph.ToModel(newParagraph); documentLogger.LogModificationToDocument(document_id); return(CreatedAtRoute("AddParagraph", new { documentid = document_id, paragraphid = modelNewParagraph.Id }, modelNewParagraph)); } catch (MissingDocumentException e) { return(BadRequest(e.Message)); } catch (Exceptions e) { return(BadRequest(e.Message)); } } return(Unauthorized()); }