예제 #1
0
        public IEnumerable <ContentInfo3PM> SearchArticles(string tagName)
        {
            var keywords =
                tagName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(i => i.Trim())
                .Where(i => i.Length > 2).ToList();

            var tags = from tag in TagBiz.Read()
                       from k in keywords
                       where tag.Text.Contains(k)
                       select tag.Id;

            var articles = from a in ArticleBiz.ReadPublishedArticles()
                           from k in keywords
                           where a.Title.Contains(k)
                           select a.Id;

            return(ArticleBiz.ReadPublishedArticles()
                   .Where(art =>
                          art.Tags.Any(tag => tags.Contains(tag.Id)) ||
                          articles.Contains(art.Id))
                   .OrderByDescending(a => a.PublishDate)
                   .MapTo <ContentInfo3PM>()
                   .ToList());
        }
예제 #2
0
 public DataSourceResult ReadUserArticles(UserIdentity user, DataSourceRequest request)
 {
     return(ArticleBiz.ReadUserContents(user.UserId, ContentType.Article)
            .OrderByDescending(a => a.PublishDate)
            .MapTo <ContentInfo5PM>()
            .ToDataSourceResult(request));
 }
예제 #3
0
        public IActionResult GetArticleInfoAsync([FromBody] GetArticleInfoRequestDto request)
        {
            var           articleBiz   = new ArticleBiz();
            var           contentBiz   = new RichtextBiz();
            AccessoryBiz  accessoryBiz = new AccessoryBiz();
            CollectionBiz collection   = new CollectionBiz();
            var           articleModel = articleBiz.GetModel(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }
            var richtextModel   = contentBiz.GetModel(articleModel.ContentGuid);
            var accessory       = accessoryBiz.GetAccessoryModelByGuid(articleModel.PictureGuid);
            var likeCount       = new LikeBiz().GetLikeNumByTargetGuid(articleModel.ArticleGuid);
            var pageViewCount   = new ArticleViewBiz().CountNumByTargetIDAsync(articleModel.ArticleGuid).Result;
            int collectionCount = collection.GetListCountByTarget(articleModel.ArticleGuid);

            return(Success(new GetArticleInfoResponseDto
            {
                ArticleTypeDic = articleModel.ArticleTypeDic,
                Abstract = articleModel.Abstract,
                Content = richtextModel?.Content,
                PictureGuid = articleModel.PictureGuid,
                Title = articleModel.Title,
                Visible = articleModel.Visible,
                PictureUrl = $"{accessory?.BasePath}{accessory?.RelativePath}",
                ArticleGuid = articleModel.ArticleGuid,
                ActcleReleaseStatus = articleModel.ActcleReleaseStatus.ToString(),
                CreationDate = articleModel.CreationDate,
                LikeCount = likeCount,
                VisitCount = pageViewCount,
                Collection = collectionCount
            }));
        }
예제 #4
0
        public VisitorHomePageModelContainer ReadStatisticsForHomePage()
        {
            var topVisits = VisitBiz.Read().GroupBy(r => r.ContentId)
                            .Select(group => new { ContentId = group.Key, TotalVisit = group.Sum(r => r.Count) })
                            .OrderByDescending(r => r.TotalVisit)
                            .Take(AppConfigurationManager.TopArticlesNumber);

            var topArticlesVisits = from a in ArticleBiz.ReadPublishedArticles()
                                    join av in topVisits
                                    on a.Id equals av.ContentId
                                    select new { a, av.TotalVisit };

            var topArticles = topArticlesVisits.OrderByDescending(t => t.TotalVisit).Select(t => t.a);

            return(new VisitorHomePageModelContainer()
            {
                TopArticles =
                    topArticles.MapTo <ContentInfo6PM>()
                    .ToList(),
                LatestArticles =
                    ArticleBiz.ReadLatestArticles(AppConfigurationManager.LatestArticlesNumber)
                    .MapTo <ContentInfo6PM>()
                    .ToList(),
                FeaturedArticles = FeaturedContentBiz.ReadFeaturedArticles().MapTo <ContentInfo6PM>().ToList(),
            });
        }
예제 #5
0
        public IActionResult GetUserArticles([FromBody] GetUserArticleRequestDto requestDto)
        {
            ArticleBiz articleBiz      = new ArticleBiz();
            var        sourceTypeWhere = string.Empty;

            if (requestDto.SourceType != null)
            {
                sourceTypeWhere = $"and source_type='{requestDto.SourceType.Value.ToString()}'";
            }
            var models = articleBiz.GetArticles(requestDto.PageIndex, requestDto.PageSize, $"where author_guid=@author_guid and actcle_release_status='Release' {sourceTypeWhere}", "last_updated_date desc", new { author_guid = requestDto.AuthorGuid });

            if (models == null)
            {
                return(Failed(ErrorCode.Empty));
            }
            var accessoryBiz  = new AccessoryBiz();
            var dictionaryBiz = new DictionaryBiz();
            var responseDtos  = new List <GetUserArticlesResponseDto>();

            foreach (var model in models)
            {
                var dto            = model.ToDto <GetUserArticlesResponseDto>();
                var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(model.PictureGuid);
                dto.Picture     = $"{accessoryModel?.BasePath}{accessoryModel?.RelativePath}";
                dto.ArticleType = dictionaryBiz.GetModelById(model.ArticleTypeDic)?.ConfigName;
                dto.PageView    = new ArticleViewBiz().CountNumByTargetIDAsync(model.ArticleGuid).Result;
                responseDtos.Add(dto);
            }
            return(Success(responseDtos));
        }
예제 #6
0
 public IEnumerable <ChartData> GetBlogPostPublishStatisticByDate()
 {
     return(ArticleBiz.Read(c => c.State == ContentState.Published && c.Type == ContentType.BlogPost, true).GroupBy(c => DbFunctions.TruncateTime(c.CreateDate))
            .Select(group => new ChartData {
         Date = group.Key.Value, Value = group.Count()
     })
            .OrderBy(p => p.Date));
 }
예제 #7
0
 public ArticleService()
 {
     UnitOfWork = new CoreUnitOfWork();
     ArticleBiz = new ArticleBiz(UnitOfWork);
     VisitBiz   = new VisitBiz(UnitOfWork);
     CommentBiz = new CommentBiz(UnitOfWork);
     TagBiz     = new TagBiz(UnitOfWork);
 }
예제 #8
0
 public IEnumerable <ContentInfo3PM> ReadArticles(int pageIndex, int pageSize)
 {
     return(ArticleBiz.ReadPublishedArticles()
            .OrderBy(blog => blog.Title)
            .Skip((pageIndex - 1) * pageSize)
            .Take(pageSize)
            .MapTo <ContentInfo3PM>()
            .ToList());
 }
예제 #9
0
        public void EditArticle(ContentRegistrationPM contentPresentationModel, IEnumerable <string> tags)
        {
            var content = contentPresentationModel.GetContent();

            content.Text = HtmlParser.Parse(content.Text);
            content.Text = HtmlMinifier.MinifyHtml(content.Text);

            ArticleBiz.UpdateContent(content, tags);
            UnitOfWork.SaveChanges();
        }
예제 #10
0
 public AppStatisticsService()
 {
     UnitOfWork         = new CoreUnitOfWork();
     ArticleBiz         = new ArticleBiz(UnitOfWork);
     BlogBiz            = new BlogBiz(UnitOfWork);
     VisitBiz           = new VisitBiz(UnitOfWork);
     UserBiz            = new UserBiz(UnitOfWork);
     CommentBiz         = new CommentBiz(UnitOfWork);
     MessageBiz         = new MessageBiz(UnitOfWork);
     FeaturedContentBiz = new FeaturedContentBiz(UnitOfWork);
 }
예제 #11
0
        public async Task <IActionResult> DisableEnableArticleAsync([FromBody] DisableEnableRequestDto request)
        {
            var articleBiz = new ArticleBiz();
            var result     = await articleBiz.DisableEnableAsync(request.Guid, request.Enable, UserID);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "修改失败"));
            }
            return(Success());
        }
예제 #12
0
        public async Task <IActionResult> DeleteArticleAsync([FromBody] DeleteRequestDto request)
        {
            var articleBiz = new ArticleBiz();
            var result     = await articleBiz.DeleteAsync(request.Guid);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "删除失败"));
            }
            return(Success());
        }
예제 #13
0
        public void ReadArticleForEdit(UserIdentity userIdentity, int contentId, out ContentRegistrationPM contentPresentationModel, out List <string> tags)
        {
            var content = ArticleBiz.Read(c =>
                                          c.AuthorId == userIdentity.UserId &&
                                          c.Type == ContentType.Article &&
                                          c.State != ContentState.Blocked &&
                                          c.Id == contentId)
                          .Include(c => c.Tags)
                          .Single();

            contentPresentationModel = content.GetContentRegistrationPM();
            tags = new List <string>(content.Tags.Select(tag => tag.Text));
        }
예제 #14
0
        public DashboardModelContainer GetUserDashboardData(int userId)
        {
            var today = DateTime.Now.Date;

            return(new DashboardModelContainer()
            {
                PendingComments = CommentBiz.ReadNotConfirmedComments(userId).Take(4).MapTo <CommentInfoPM>().ToList(),
                ArticlesCount = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(),
                BlogPostsCount = BlogBiz.ReadUserTotalPublishedPostsCount(userId),
                TodayTotallVisits = VisitBiz.ReadUserTodayTotalVisits(userId),
                LatestMessages = MessageBiz.ReadUserMessages(userId, 4).MapTo <MessagePM>().ToList()
            });
        }
예제 #15
0
        public void AddArticle(ContentRegistrationPM contentPresentationModel, IEnumerable <string> tags)
        {
            var content = contentPresentationModel.GetContent();

            content.Type        = ContentType.Article;
            content.CultureLcid = CultureInfo.GetCultureInfo("fa-IR").LCID;
            content.Text        = HtmlParser.Parse(content.Text);
            content.Text        = HtmlMinifier.MinifyHtml(content.Text);

            ArticleBiz.AddContent(content, tags);
            UnitOfWork.SaveChanges();
            contentPresentationModel.Id = content.Id;
        }
 public UserProfileService()
 {
     UnitOfWork           = new CoreUnitOfWork();
     UserBiz              = new UserBiz(UnitOfWork);
     MembershipBiz        = new MembershipBiz(UnitOfWork);
     ProfileBiz           = new ProfileBiz(UnitOfWork);
     ArticleBiz           = new ArticleBiz(UnitOfWork);
     BlogBiz              = new BlogBiz(UnitOfWork);
     EducationalResumeBiz = new EducationalResumeBiz(UnitOfWork);
     VisitBiz             = new VisitBiz(UnitOfWork);
     JobResumeBiz         = new JobResumeBiz(UnitOfWork);
     FollowBiz            = new FollowBiz(UnitOfWork);
 }
예제 #17
0
        public async Task <IActionResult> GetClientArticleDetailAsync(string articleGuid, ArticleModel.ArticleSourceTypeEnum articleSource = ArticleModel.ArticleSourceTypeEnum.Doctor)
        {
            if (string.IsNullOrWhiteSpace(articleGuid))
            {
                return(Failed(ErrorCode.UserData, "文章Id articleGuid 不可为空"));
            }


            var        response   = new GetClientArticleDetailResponseDto();
            ArticleBiz articleBiz = new ArticleBiz();
            var        model      = articleBiz.GetModel(articleGuid);

            if (model == null)
            {
                return(Failed(ErrorCode.Empty));
            }
            var doctorBiz    = new DoctorBiz();
            var accessoryBiz = new AccessoryBiz();
            var userBiz      = new UserBiz();
            var likeBiz      = new LikeBiz();
            var richtextBiz  = new RichtextBiz();

            response.ArticleGuid     = model.ArticleGuid;
            response.Title           = model.Title;
            response.AuthorGuid      = model.AuthorGuid;
            response.LastUpdatedDate = model.LastUpdatedDate;
            response.Content         = richtextBiz.GetModel(model.ContentGuid)?.Content;
            response.LikeNumber      = likeBiz.GetLikeNumByTargetGuid(articleGuid);
            response.Liked           = likeBiz.GetLikeState(UserID, articleGuid);
            if (articleSource == ArticleModel.ArticleSourceTypeEnum.Doctor)
            {
                response.AuthorName = userBiz.GetUser(model.AuthorGuid)?.UserName;
                var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid);
                if (doctorModel != null)
                {
                    var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid);
                    response.AuthorPortrait = accessoryModel?.BasePath + accessoryModel?.RelativePath;
                    response.HospitalName   = doctorModel.HospitalName;
                    response.OfficeName     = doctorModel.OfficeName;
                }
            }
            else if (articleSource == ArticleModel.ArticleSourceTypeEnum.Manager)
            {
                response.AuthorName = (await new ManagerAccountBiz().GetAsync(model.AuthorGuid))?.UserName;
            }
            else
            {
                return(Failed(ErrorCode.UserData, $"文章来源 articleSource:{articleSource.ToString()} 数据值非法"));
            }
            return(Success(response));
        }
예제 #18
0
        public ViewArticleModelContainer ReadArticleForPreview(int contentId)
        {
            var content = ArticleBiz.ReadArticleForPreview(contentId);

            return(new ViewArticleModelContainer()
            {
                Article = content.GetContentForViewByVisitorPM(),
                Tags = content.Tags.Select(tag => tag.GetPresentationModel()).ToList(),
                AuthorProfile = new ProfileForViewByVisitorPM()
                {
                    AboutMe = content.Author.ProfileKeyValues.SingleOrDefault(profileKeyValye =>
                                                                              profileKeyValye.Type == ProfileKeyValueType.AboutMe)?.Value
                },
            });
        }
예제 #19
0
        public ViewArticleModelContainer ReadArticleForViewByVisitor(int contentId)
        {
            var content = ArticleBiz.ReadArticleForViewByVisitor(contentId);

            VisitBiz.IncrementContentVisits(contentId);
            UnitOfWork.SaveChanges();
            int totalVisits = 0;

            try
            {
                totalVisits = VisitBiz.Read(e => e.ContentId == contentId).Sum(e => e.Count);
            }
            catch (InvalidOperationException ex)
            {
            }

            var result = new ViewArticleModelContainer()
            {
                Article       = content.GetContentForViewByVisitorPM(),
                Tags          = content.Tags.Select(tag => tag.GetPresentationModel()).ToList(),
                AuthorProfile = new ProfileForViewByVisitorPM()
                {
                    AboutMe = content.Author.ProfileKeyValues.SingleOrDefault(profileKeyValye =>
                                                                              profileKeyValye.Type == ProfileKeyValueType.AboutMe)?.Value
                },
                AuthorBusinessIntroduce = new BusinessIntroducePM()
                {
                    Text = content.Author.ProfileKeyValues.SingleOrDefault(profileKeyValye =>
                                                                           profileKeyValye.Type == ProfileKeyValueType.UserBusinessIntroduceText)?.Value
                },
                Comments            = CommentBiz.GetArticleComments(content.Id).MapTo <CommentInfoPM>().ToList(),
                UserRelatedArticles = ArticleBiz.ReadUserRelatedArticles(content.AuthorId, contentId, 10)
                                      .MapTo <ContentInfo4PM>()
                                      .ToList(),
                RelatedArticles = ArticleBiz.ReadRelatedArticles(content.AuthorId, contentId, 10)
                                  .MapTo <ContentInfo4PM>()
                                  .ToList(),
                TotalVisits = VisitBiz.Read(e => e.ContentId == contentId).Sum(e => e.Count)
            };

            if (result.UserRelatedArticles.Count == 0 && result.RelatedArticles.Count == 0)
            {
                result.TopArticles = ArticleBiz.ReadTopArticles(10)
                                     .MapTo <ContentInfo4PM>()
                                     .ToList();
            }
            return(result);
        }
예제 #20
0
        public AdminDashboardModelContainer GetAdminDashboardStatistics()
        {
            var today = DateTime.Now.Date;

            return(new AdminDashboardModelContainer()
            {
                TodayVisitsCount =
                    VisitBiz.GetTodaySiteTotalVisitsCount(),
                TotalArticlesCount =
                    ArticleBiz.Read(c => c.State == ContentState.Published && c.Type == ContentType.Article).Count(),
                TotalBlogPostCount =
                    ArticleBiz.Read(c => c.State == ContentState.Published && c.Type == ContentType.BlogPost).Count(),
                TotalUsersCount = UserBiz.Read().Count(),
                NewUsers = UserBiz.GetNewUsers(top: 3).MapTo <AdminDashboardNewUserPm>().ToList(),
                NewArticles = ArticleBiz.ReadLatestArticles(3).MapTo <AdminDashboardNewArticlePm>().ToList()
            });
        }
예제 #21
0
        public async Task <IActionResult> SetArticleVisibleAsync([FromBody] SetArticleVisibleRequestDto request)
        {
            var articleBiz   = new ArticleBiz();
            var articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }
            articleModel.Visible = request.Visible;
            var response = await articleBiz.UpdateAsync(articleModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "跟新失败"));
            }
            return(Success());
        }
예제 #22
0
        public async Task <IActionResult> RemoveArticleAsync(string articleId)
        {
            var articleBiz   = new ArticleBiz();
            var articleModel = await articleBiz.GetAsync(articleId);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查询到该文章数据"));
            }
            articleModel.LastUpdatedBy   = UserID;
            articleModel.LastUpdatedDate = DateTime.Now;
            var result = await articleBiz.DeleteArticleAsync(articleModel);

            if (result && articleModel.ActcleReleaseStatus == ReleaseStatus.Release)
            {
                new DoctorActionBiz().DeleteArticleAsync(this.UserID);
            }
            return(Success(result));
        }
예제 #23
0
        public async Task <IActionResult> UpdateArticleAsync([FromBody] UpdateArticleRequestDto request)
        {
            var articleBiz   = new ArticleBiz();
            var contentBiz   = new RichtextBiz();
            var articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }

            var richtextModel = await contentBiz.GetAsync(articleModel.ContentGuid);

            richtextModel.Content         = request.Content;
            richtextModel.LastUpdatedBy   = UserID;
            richtextModel.LastUpdatedDate = DateTime.Now;
            richtextModel.OrgGuid         = string.Empty;
            richtextModel.OwnerGuid       = request.ArticleGuid;

            articleModel.Abstract            = request.Abstract;
            articleModel.ArticleTypeDic      = request.ArticleTypeDic;
            articleModel.LastUpdatedBy       = UserID;
            articleModel.LastUpdatedDate     = DateTime.Now;
            articleModel.Sort                = 1;
            articleModel.Title               = request.Title;
            articleModel.Visible             = request.Visible;
            articleModel.PictureGuid         = request.PictureGuid;
            articleModel.ActcleReleaseStatus = Enum.Parse <ReleaseStatus>(request.ActcleReleaseStatus);

            var response = await new ArticleBiz().UpdateAsync(richtextModel, articleModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "修改失败"));
            }
            //发布时才添加积分
            if (articleModel.ActcleReleaseStatus == ReleaseStatus.Release)
            {
                new DoctorActionBiz().AddArticleAsync(this.UserID);
            }
            return(Success(response));
        }
        public ProfileStatisticsAndSocialLinksPM ReadProfileStatisticsAndSocialLinks(int userId)
        {
            var userLinks = ProfileBiz.ReadUserProfileValues(userId,
                                                             ProfileKeyValueType.WebSiteUrl,
                                                             ProfileKeyValueType.FacebookUrl,
                                                             ProfileKeyValueType.TwitterUrl,
                                                             ProfileKeyValueType.LinkedInUrl);
            var articlesCount = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count();
            var blogsCount    = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count();

            return(new ProfileStatisticsAndSocialLinksPM()
            {
                WebSiteUrl = userLinks.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.WebSiteUrl)?.Value,
                FacebookUrl = userLinks.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.FacebookUrl)?.Value,
                TwitterUrl = userLinks.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.TwitterUrl)?.Value,
                LinkedInUrl = userLinks.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.LinkedInUrl)?.Value,
                TotalArticles = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(),
                TotalBlogPosts = ArticleBiz.ReadUserPublishedContents(userId, ContentType.BlogPost).Count(),
                TotalVisits = VisitBiz.ReadUserTodayTotalVisits(userId),
            });
        }
예제 #25
0
        public IActionResult GetCupationalDiseaseKnowledge([FromBody] GetCcupationalDiseaseKnowledgeRequestDto dto)
        {
            ArticleBiz articleBiz   = new ArticleBiz();
            var        condition    = "where article_type_dic=@article_type_dic and visible=true and enable=true ";
            var        lst          = articleBiz.GetArticles(dto.PageNumber, dto.PageSize, condition, "creation_date desc", new { article_type_dic = DictionaryType.OccupationalDiseaseKnowledge });
            var        accessoryBiz = new AccessoryBiz();
            var        dtos         = new List <GetCcupationalDiseaseKnowledgeResponseDto>();

            foreach (var item in lst)
            {
                var model   = item.ToDto <GetCcupationalDiseaseKnowledgeResponseDto>();
                var picture = MySqlHelper.GetModelById <AccessoryModel>(item.PictureGuid);
                model.Picture = $"{picture?.BasePath}{picture?.RelativePath}";
                dtos.Add(model);
            }
            if (dtos.Count == 0)
            {
                return(Failed(ErrorCode.Empty));
            }
            return(Success(dtos));
        }
        public UserInfoForHomePageModelContainer ReadUserInfoForProfilePage(int userId, UserIdentity userIdentity)
        {
            var user = UserBiz.Read(u => u.Id == userId)
                       .Include(u => u.Membership)
                       .Include(u => u.EducationalResumes.Select(x => x.Organization))
                       .Include(u => u.EducationalResumes.Select(x => x.UniversityField))
                       .Include(u => u.JobResumes.Select(x => x.Organization))
                       .Include(u => u.JobResumes.Select(x => x.Job))
                       .Single();
            var profileKeyValues = ProfileBiz.ReadUserProfileValues(userId,
                                                                    ProfileKeyValueType.WebSiteUrl,
                                                                    ProfileKeyValueType.FacebookUrl,
                                                                    ProfileKeyValueType.TwitterUrl,
                                                                    ProfileKeyValueType.LinkedInUrl,
                                                                    ProfileKeyValueType.AboutMe);
            var userBlog = BlogBiz.ReadSingleOrDefault(b => b.CreatorId == userId);

            return(new UserInfoForHomePageModelContainer()
            {
                UserId = userId,
                FirstName = user.FirstName,
                LastName = user.LastName,
                AboutMe = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.AboutMe)?.Value,
                WebSiteUrl = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.WebSiteUrl)?.Value,
                FacebookUrl = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.FacebookUrl)?.Value,
                TwitterUrl = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.TwitterUrl)?.Value,
                LinkedInUrl = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.LinkedInUrl)?.Value,
                TotalArticles = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(),
                TotalBlogPosts = ArticleBiz.ReadUserPublishedContents(userId, ContentType.BlogPost).Count(),
                TotalVisits = VisitBiz.ReadUserTodayTotalVisits(userId),
                LatestArticles = ArticleBiz.ReadUserLatestPublishedArticles(userId, 200).MapTo <ContentInfo2PM>().ToList(),
                LatestBlogPosts = BlogBiz.ReadUserLatestPosts(userId, 5).MapTo <ContentInfo2PM>().ToList(),
                EducationalResumes = user.EducationalResumes.OrderByDescending(x => x.EducationGrade).Select(x => x.GetPresentationModel()).ToList(),
                JobResumes = user.JobResumes.OrderByDescending(x => x.StartYear).Select(x => x.GetPresentationModel()).ToList(),
                WeblogName = userBlog?.Name,
                RegistrationDateString = user.Membership.CreateDate.ToPersianDate(),
                CurrentUserFollowsThisUser = userIdentity != null?FollowBiz.AnyFollow(userIdentity.UserId, userId) : false,
                                                 Followers = FollowBiz.ReadFollowersCount(userId)
            });
        }
예제 #27
0
        public async Task <IActionResult> UpdateArticleAsync([FromBody] UpdateArticleRequestDto request)
        {
            var articleBiz   = new ArticleBiz();
            var contentBiz   = new RichtextBiz();
            var articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }
            var richtextModel = await contentBiz.GetAsync(articleModel.ContentGuid);

            richtextModel.Content         = request.Content;
            richtextModel.LastUpdatedBy   = UserID;
            richtextModel.LastUpdatedDate = DateTime.Now;
            richtextModel.OrgGuid         = string.Empty;
            richtextModel.OwnerGuid       = request.ArticleGuid;

            articleModel.Abstract            = request.Abstract;
            articleModel.ArticleTypeDic      = request.ArticleTypeDic;
            articleModel.LastUpdatedBy       = UserID;
            articleModel.LastUpdatedDate     = DateTime.Now;
            articleModel.Sort                = 1;
            articleModel.Title               = request.Title;
            articleModel.Enable              = request.Enable;
            articleModel.Visible             = request.Visible;
            articleModel.PictureGuid         = request.PictureGuid;
            articleModel.ActcleReleaseStatus = Enum.Parse <Models.Utility.ReleaseStatus>(request.ActcleReleaseStatus.ToString());
            articleModel.Keyword             = JsonConvert.SerializeObject(request.Keyword);
            articleModel.ExternalLink        = request.ExternalLink ?? string.Empty;

            var response = await new ArticleBiz().UpdateAsync(richtextModel, articleModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "修改失败"));
            }
            return(Success(response));
        }
예제 #28
0
        //public

        public void Format()
        {
            ArticleStock = ArticleBiz.ParseArticle(this.Text, Stocks);
            ArticleStock.ForEach(stock =>
            {
                var index = 0;
                do
                {
                    index = this.Text.IndexOf(stock.StockName, index + 1);
                    if (index > 0)
                    {
                        this.Select(index, stock.StockName.Length);
                        this.SelectionColor = Color.Red;
                        //ArticleStock.Add(stock);
                    }
                } while (index > 0);

                do
                {
                    index = this.Text.IndexOf(stock.StockCode, index + 1);
                    if (index > 0)
                    {
                        this.Select(index, stock.StockName.Length);
                        this.SelectionColor = Color.Red;
                        //ArticleStock.Add(stock);
                    }
                } while (index > 0);
            });
            if (ArticleStock.Count > 0)
            {
                ArticleStock = ArticleStock.Distinct().ToList();
                this.AppendText(Environment.NewLine);
                this.AppendText(Environment.NewLine);
                this.AppendText(ArticleStock.Select(stock => stock.StockName)
                                .Aggregate((a, b) => a + "," + b));
            }
        }
예제 #29
0
 public int ReadTotallPublishedArticlesCount()
 {
     return(ArticleBiz.ReadTotalPublishedArticlesCount());
 }
 public TagService()
 {
     UnitOfWork = new CoreUnitOfWork();
     TagBiz     = new TagBiz(UnitOfWork);
     ArticleBiz = new ArticleBiz(UnitOfWork);
 }