public async Task <ContentDto> CreateContent(CreateContentInput input)
        {
            var content = new Content(input.AppId, input.ChannelId, input.Title, input.ContentText);
            var app     = await _appManager.GetByIdAsync(content.AppId);

            content.Author       = input.Author;
            content.CheckedLevel = input.CheckedLevel;
            content.Comments     = input.Comments;
            content.ContentGroupNameCollection = input.ContentGroupNameCollection;
            content.FileUrl     = PageUtils.GetUrlWithoutAppDir(app, input.FileUrl);
            content.Hits        = input.Hits;
            content.HitsByDay   = input.HitsByDay;
            content.HitsByMonth = input.HitsByMonth;
            content.HitsByWeek  = input.HitsByWeek;
            content.ImageUrl    = PageUtils.GetUrlWithoutAppDir(app, input.ImageUrl);
            content.IsChecked   = input.IsChecked;
            content.IsColor     = input.IsColor;
            content.IsHot       = input.IsHot;
            content.IsRecommend = input.IsRecommend;
            content.IsTop       = input.IsTop;
            content.VideoUrl    = PageUtils.GetUrlWithoutAppDir(app, input.VideoUrl);

            await _contentManager.CreateAsync(content);

            //await CurrentUnitOfWork.SaveChangesAsync();
            return(content.MapTo <ContentDto>());
        }
示例#2
0
        // Inserts or updates the Contents based on the id value inserted.
        public async Task <CMSContent> InsertOrUpdateCMSContent(CreateContentInput input)
        {
            try
            {
                var exists = await _contentRepository
                             .GetAll()
                             .AnyAsync(e => e.Id == input.Id);

                if (!exists)
                {
                    var @content = CMSContent.CreateContent(input.PageName, input.PageContent);
                    return(await _contentRepository.InsertAsync(@content));
                }
                else
                {
                    var @content = CMSContent.CreateContent(input.Id, input.PageName, input.PageContent);
                    return(await _contentRepository.UpdateAsync(@content));
                }
            }
            catch (Exception e)
            {
                // To do :Log the message somewhere
                throw new UserFriendlyException($"There was an error while inserting/updating the contect . Please contact Us {0}", e.StackTrace);
            }
        }
示例#3
0
        public async Task <Content> CreateContent(
            [Service] IAsyncCreateStrategy <Content, CreateContentInput> strategy,
            CreateContentInput content
            )
        {
            var result = await strategy.CreateAsync(content);

            return(result);
        }
示例#4
0
        public async Task <ContentDto> CreateContent(CreateContentInput input)
        {
            var content = new Content(input.AppId, input.ChannelId, input.Title, input.ContentText);
            await _contentManager.CreateAsync(content);

            await CurrentUnitOfWork.SaveChangesAsync();

            return(content.MapTo <ContentDto>());
        }