public IHttpActionResult GetHeadersText([FromUri] Guid header_id)
        {
            if (IsTokenValid() && authenticationService.IsAllowedToGetHeaders(GetTokenUserEmail(), header_id))
            {
                return(Ok(BaseText.ToModel(textManagementService.GetByHeader(header_id))));
            }

            return(Unauthorized());
        }
示例#2
0
        public IHttpActionResult GetParagraphsTexts([FromUri] Guid paragraph_id)
        {
            if (IsTokenValid() && authenticationService.IsAllowedToGetParagraphs(GetTokenUserEmail(), paragraph_id))
            {
                try
                {
                    return(Ok(BaseText.ToModel(textManagementService.GetAllByParagraph(paragraph_id))));
                }
                catch (Exceptions e)
                {
                    return(BadRequest(e.Message));
                }
            }

            return(Unauthorized());
        }
示例#3
0
        public IHttpActionResult GetFootersText([FromUri] Guid footer_id)
        {
            if (IsTokenValid() && authenticationService.IsAllowedToGetFooters(GetTokenUserEmail(), footer_id))
            {
                try
                {
                    return(Ok(BaseText.ToModel(textManagementService.GetByFooter(footer_id))));
                }
                catch (MissingFooterException e)
                {
                    return(BadRequest(e.Message));
                }
                catch (Exceptions e)
                {
                    return(BadRequest(e.Message));
                }
            }

            return(Unauthorized());
        }
示例#4
0
        public IHttpActionResult AddTextToParagraph([FromUri] Guid paragraph_id, [FromBody] AddText text)
        {
            if (IsTokenValid() && authenticationService.IsAllowedToUpdateParagraphs(GetTokenUserEmail(), paragraph_id))
            {
                try
                {
                    Text     newText      = textManagementService.AddToParagraph(paragraph_id, AddText.ToEntity(text));
                    BaseText modelNewText = BaseText.ToModel(newText);
                    documentLogger.LogModificationToParagraph(paragraph_id);

                    return(CreatedAtRoute("AddTextToParagraph", new { paragraphid = paragraph_id, textid = modelNewText.Id }, modelNewText));
                }
                catch (MissingParagraphException e)
                {
                    return(BadRequest(e.Message));
                }
                catch (Exceptions e)
                {
                    return(BadRequest(e.Message));
                }
            }

            return(Unauthorized());
        }