public async Task <ActionResult <DataBlockViewModel> > UpdateDataBlock(
     Guid releaseId, Guid contentSectionId, Guid contentBlockId, DataBlockUpdateRequest request)
 {
     return(await _contentService
            .UpdateDataBlock(releaseId, contentSectionId, contentBlockId, request)
            .HandleFailuresOrOk());
 }
        public Task <Either <ActionResult, DataBlockViewModel> > UpdateDataBlock(
            Guid releaseId, Guid contentSectionId, Guid contentBlockId, DataBlockUpdateRequest 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 <DataBlockViewModel>();
                }

                if (!(blockToUpdate is DataBlock dataBlock))
                {
                    return ValidationActionResult(IncorrectContentBlockTypeForUpdate);
                }

                return await UpdateDataBlock(dataBlock, request);
            }));
        }
        private async Task <Either <ActionResult, DataBlockViewModel> > UpdateDataBlock(DataBlock blockToUpdate,
                                                                                        DataBlockUpdateRequest request)
        {
            if (blockToUpdate.Summary == null)
            {
                blockToUpdate.Summary = new DataBlockSummary();
            }

            blockToUpdate.Summary.DataDefinitionTitle = new List <string>
            {
                request.DataDefinitionTitle
            };

            blockToUpdate.Summary.DataDefinition = new List <string>
            {
                request.DataDefinition
            };

            blockToUpdate.Summary.DataSummary = new List <string>
            {
                request.DataSummary
            };

            return(await SaveContentBlock <DataBlockViewModel>(blockToUpdate));
        }