Example #1
0
        public void SaveUseMainLayout(long mediaDetailId, string html)
        {
            if (FrameworkSettings.CurrentUser == null)
            {
                var returnObj = BaseMapper.GenerateReturn("You must be logged in");
                WriteJSON(returnObj.ToJson());
                return;
            }

            var mediaDetail = (MediaDetail)MediaDetailsMapper.GetByID(mediaDetailId);

            var history = (MediaDetail)MediaDetailsMapper.CreateHistory(mediaDetail, false);

            mediaDetail.History.Add(history);

            if (!FrameworkSettings.CurrentUser.HasPermission(PermissionsEnum.Save))
            {
                var returnObj = BaseMapper.GenerateReturn("You do not have permissions to perform this operation");
                WriteJSON(returnObj.ToJson());
                return;
            }

            if (mediaDetail != null)
            {
                mediaDetail.UseMediaTypeLayouts = false;

                html = Uri.UnescapeDataString(html);
                //html = MediaDetailsMapper.ConvertUrlsToShortCodes(html);

                html = html.Replace(URIHelper.BaseUrl, "{BaseUrl}");

                mediaDetail.MainLayout = html;

                var returnObj = MediaDetailsMapper.Update(mediaDetail);

                WriteJSON(returnObj.ToJson());
            }
            else
            {
                WriteJSON(new Return()
                {
                    Error = new Elmah.Error()
                    {
                        Message = $"MediaDetail with the ID '{mediaDetailId}' was not found"
                    }
                }.ToJson());
            }
        }
Example #2
0
 private IMediaDetail CreateHistory(bool isDraft)
 {
     return(MediaDetailsMapper.CreateHistory((MediaDetail)selectedItem, isDraft));
 }