Example #1
0
        public static CustomRichTextDto UpdateCustomRichText(NebulaDbContext dbContext, int customRichTextTypeID,
                                                             CustomRichTextDto customRichTextUpdateDto)
        {
            var customRichText = dbContext.CustomRichText
                                 .SingleOrDefault(x => x.CustomRichTextTypeID == customRichTextTypeID);

            // null check occurs in calling endpoint method.
            customRichText.CustomRichTextContent = customRichTextUpdateDto.CustomRichTextContent;

            dbContext.SaveChanges();

            return(customRichText.AsDto());
        }
Example #2
0
        public ActionResult <CustomRichTextDto> UpdateCustomRichText([FromRoute] int customRichTextTypeID,
                                                                     [FromBody] CustomRichTextDto customRichTextUpdateDto)
        {
            var customRichTextDto = CustomRichText.GetByCustomRichTextTypeID(_dbContext, customRichTextTypeID);

            if (ThrowNotFound(customRichTextDto, "Custom Rich Text", customRichTextTypeID, out var actionResult))
            {
                return(actionResult);
            }

            var updatedCustomRichTextDto = CustomRichText.UpdateCustomRichText(_dbContext, customRichTextTypeID, customRichTextUpdateDto);

            return(Ok(updatedCustomRichTextDto));
        }