public IHttpActionResult Delete([FromUri] Guid id)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         DocumentBusinessLogic.DeleteDocument(id);
         AuditLogBussinesLogic.CreateLog("Document", id, Utils.GetUsername(Request), ActionPerformed.DELETE);
         return(Ok("Document deleted"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public IHttpActionResult Post([FromBody] DocumentModel documentModel)
        {
            try
            {
                Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
                documentModel.CreatorUser = Utils.GetCreatorUser(Request, UserBusinessLogic);

                DocumentBusinessLogic.AddDocument(documentModel.ToEntity());
                AuditLogBussinesLogic.CreateLog("Document", documentModel.Id, Utils.GetUsername(Request), ActionPerformed.CREATE);
                return(Ok(documentModel));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public IHttpActionResult Put([FromUri] Guid id, [FromBody] DocumentModel documentModel)
        {
            try
            {
                Utils.IsAValidToken(Request, AuthorizationBusinessLogic);

                documentModel.Id = id;

                DocumentBusinessLogic.ModifyDocument(documentModel.ToEntity());
                AuditLogBussinesLogic.CreateLog("Document", documentModel.Id, Utils.GetUsername(Request), ActionPerformed.MODIFY);
                return(Ok("Document Modified"));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public IHttpActionResult Post([FromUri] Guid documentId, [FromUri] int index, [FromBody] ParagraphModel documentPart)
        {
            try
            {
                Utils.IsAValidToken(Request, AuthorizationBusinessLogic);

                var paragraph = documentPart.ToEntity();
                DocumentBusinessLogic.AddDocumentParagraphAt(documentId, index, paragraph);

                AuditLogBussinesLogic.CreateLog("Document", documentId, Utils.GetUsername(Request), ActionPerformed.MODIFY);
                return(Ok(documentPart));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public IHttpActionResult Post([FromUri] Guid documentId, [FromUri] MarginAlign align, [FromBody] MarginModel documentPart)
        {
            try
            {
                Utils.IsAValidToken(Request, AuthorizationBusinessLogic);

                var body = documentPart.ToEntity();
                DocumentBusinessLogic.SetDocumentMargin(documentId, align, body);

                AuditLogBussinesLogic.CreateLog("Document", documentId, Utils.GetUsername(Request), ActionPerformed.MODIFY);
                return(Ok(documentPart));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }