Example #1
0
 public async Task <ActionResult <IContentBlockViewModel> > UpdateTextBasedContentBlock(
     Guid methodologyId, Guid contentSectionId, Guid contentBlockId, UpdateTextBasedContentBlockRequest request)
 {
     return(await _contentService
            .UpdateTextBasedContentBlockAsync(methodologyId, contentSectionId, contentBlockId, request)
            .HandleFailuresOrOk());
 }
Example #2
0
        public Task <Either <ActionResult, IContentBlockViewModel> > UpdateTextBasedContentBlockAsync(
            Guid releaseId, Guid contentSectionId, Guid contentBlockId, UpdateTextBasedContentBlockRequest request)
        {
            return(CheckContentSectionExists(releaseId, contentSectionId)
                   .OnSuccess(CheckCanUpdateRelease)
                   .OnSuccess(async tuple =>
            {
                var(_, section) = tuple;

                var blockToUpdate = section.Content.Find(block => block.Id == contentBlockId);

                if (blockToUpdate == null)
                {
                    return NotFound <IContentBlockViewModel>();
                }

                return blockToUpdate switch
                {
                    MarkDownBlock markDownBlock => await UpdateMarkDownBlock(markDownBlock, request.Body),
                    HtmlBlock htmlBlock => await UpdateHtmlBlock(htmlBlock, request.Body),
                    DataBlock _ => ValidationActionResult(IncorrectContentBlockTypeForUpdate),
                    _ => throw new ArgumentOutOfRangeException()
                };
            }));
        }
Example #3
0
        public Task <Either <ActionResult, IContentBlockViewModel> > UpdateTextBasedContentBlockAsync(
            Guid methodologyId, Guid contentSectionId, Guid contentBlockId, UpdateTextBasedContentBlockRequest request)
        {
            return(CheckContentSectionExists(methodologyId, contentSectionId)
                   .OnSuccess(CheckCanUpdateMethodology)
                   .OnSuccess(EnsureContentBlockListNotNull)
                   .OnSuccess(async tuple =>
            {
                var(methodology, section) = tuple;

                var blockToUpdate = section.Content.Find(block => block.Id == contentBlockId);

                if (blockToUpdate == null)
                {
                    return NotFound <IContentBlockViewModel>();
                }

                return blockToUpdate switch
                {
                    HtmlBlock htmlBlock => await UpdateHtmlBlock(htmlBlock, request.Body, methodology),
                    _ => throw new ArgumentOutOfRangeException()
                };
            }));
        }