Example #1
0
        /// <summary>
        /// ページの取得
        /// </summary>
        /// <param name="pageSize">1ページあたりのレコード件数</param>
        /// <param name="pageNo">ページ番号</param>
        /// <returns>ActionResult</returns>
        public ActionResult Index(long memberId, int? page, int? year, int? month)
        {
            //int pageNo = 1;
            //int pageSize = 3;

            //UserArticleViewModel viewModel = new UserArticleViewModel();

            Member member = Utils.GetMember(memberId);
            ViewBag.MemberId = memberId;
            ViewBag.Nickname = member.Nickname;

            ViewBag.OtherMemberID = memberId;
            ViewBag.OtherMemberNickName = member.Nickname;

            //ViewBag.PageNo = pageNo;
            //ViewBag.PageSize = pageSize;
            //SetArticles(viewModel, memberId, 0, UserArticleViewModel.INITIAL_SIZE);

            //return View(viewModel);
            var articleListDefault = PostedController.GetRecentPosts(10,Convert.ToInt32(memberId));
            if (articleListDefault != null)
            {
                int pageNumber = (page ?? 1);
                int postYear = (year != null) ? year.Value : DateTime.Now.Year;
                int postMonth = DateTime.Now.Month;
                var spara = com.SystemParamater.Find(1);
                int pageSize = 10;
                if (spara != null)
                    pageSize = Convert.ToInt32(spara.Spara);

                var postMothList = new UserArticleMonthListViewModel();
                postMothList.Year = postYear;
                postMothList.YearList = (from a in articleListDefault
                                         select a).GroupBy(m => m.PostYear).Select(l => l.Key).ToList();
                if (postMothList.YearList != null)
                    postMothList.YearList.Sort();
                postMothList.YearList.Sort();
                postMothList.MonthList = (from a in articleListDefault
                                          where a.PostYear == postYear
                                          select a).GroupBy(m => m.PostMonth).Select(l => l.Key).ToList();
                if (postMothList.MonthList != null && postMothList.MonthList.Any())
                {
                    postMothList.MonthList.Sort();
                    if (month != null)
                        postMonth = month.Value;
                    else
                        postMonth = postMothList.MonthList.LastOrDefault();
                }
                ViewBag.PostMonth = postMonth;

                // get main list of articles
                postMothList.PostList = (from a in articleListDefault
                                         where a.PostYear == postYear && a.PostMonth == postMonth
                                         select a).ToPagedList(pageNumber, pageSize);

                DateTime yesterday = DateTime.Now.AddDays(-1).Date;
                DateTime yesterdayEnd = DateTime.Today.Date;
                postMothList.MostViewTopicList = from p in com.PopularTopicsAggregate
                                                 join t in com.TopicMaster on p.TopicID equals t.TopicID
                                                 where p.TargetDate >= yesterday && p.TargetDate < yesterdayEnd
                                                 orderby p.Views descending
                                                 select t;
                return View(postMothList);
            }
            return View();
        }
Example #2
0
        public ActionResult Index(int? page, int? year, int? month)
        {
            //Todo:認証処理 AOPでやりたい。 一旦Session変数を参照し判定
            if (Session["CurrentUser"] == null)
            {
                return RedirectToActionPermanent("Login", "Member", new { area = "" });
            }

            //MyPageArticleViewModel viewModel = new MyPageArticleViewModel();

            //DBから取得する処理
            //SetLines(viewModel, 0, MyPageArticleViewModel.INITIAL_SIZE);
            var articleListDefault = PostedController.GetRecentPosts(9);
            if (articleListDefault != null)
            {
                int pageNumber = (page ?? 1);
                int postYear = (year != null) ? year.Value : DateTime.Now.Year;
                int postMonth = DateTime.Now.Month;
                var spara = com.SystemParamater.Find(1);
                int pageSize = 10;
                if (spara != null)
                    pageSize = Convert.ToInt32(spara.Spara);

                var postMothList = new UserArticleMonthListViewModel();
                postMothList.Year = postYear;
                postMothList.YearList = (from a in articleListDefault
                                         select a).GroupBy(m => m.PostYear).Select(l => l.Key).ToList();
                if (postMothList.YearList != null)
                    postMothList.YearList.Sort();
                postMothList.YearList.Sort();
                postMothList.MonthList = (from a in articleListDefault
                                          where a.PostYear == postYear
                                          select a).GroupBy(m => m.PostMonth).Select(l => l.Key).ToList();
                if (postMothList.MonthList != null && postMothList.MonthList.Any())
                {
                    postMothList.MonthList.Sort();
                    if (month != null)
                        postMonth = month.Value;
                    else
                        postMonth = postMothList.MonthList.LastOrDefault();
                }
                ViewBag.PostMonth = postMonth;

                // get main list of articles
                postMothList.PostList = (from a in articleListDefault
                                         where a.PostYear == postYear && a.PostMonth == postMonth
                                         select a).ToPagedList(pageNumber, pageSize);

                DateTime yesterday = DateTime.Now.AddDays(-1).Date;
                DateTime yesterdayEnd = DateTime.Today.Date;
                postMothList.MostViewTopicList = from p in com.PopularTopicsAggregate
                                                 join t in com.TopicMaster on p.TopicID equals t.TopicID
                                                 where p.TargetDate >= yesterday && p.TargetDate < yesterdayEnd
                                                 orderby p.Views descending
                                                 select t;
                return View(postMothList);
            }
            return View();
        }
Example #3
0
        public ActionResult Index(int? page, int? year, int? month)
        {
            var articleListDefault = default(IEnumerable<PostedInfoViewModel>);
            if (Session["CurrentUser"] != null)
            {
                var memberId = Convert.ToInt64(Session["CurrentUser"].ToString());
                var email = memberContext.Member.SingleOrDefault(m => m.MemberId == memberId).Mail;
                var username = memberContext.Member.SingleOrDefault(m => m.MemberId == memberId).Nickname;

                ViewBag.UserName = username;
                ViewBag.CurrentPage = "投稿記事トップ";

                articleListDefault = PostedController.GetRecentPosts(5);
            }
            else
            {
                articleListDefault = PostedController.GetRecentPosts(4);
            }
            if (articleListDefault != null)
            {
                int pageNumber = (page ?? 1);
                var postYear = (year == null) ? DateTime.Now.Year : year.Value;
                var postMonth = DateTime.Now.Month;
                var spara = memberContext.SystemParamater.Find(1);
                int pageSize = 10;
                if (spara != null)
                    pageSize = Convert.ToInt32(spara.Spara);

                var postMothList = new UserArticleMonthListViewModel();
                postMothList.Year = postYear;
                postMothList.YearList = (from a in articleListDefault
                                         select a).GroupBy(m => m.PostYear).Select(l => l.Key).ToList();
                if (postMothList.YearList != null)
                    postMothList.YearList.Sort();
                postMothList.YearList.Sort();
                postMothList.MonthList = (from a in articleListDefault
                                          where a.PostYear == postYear
                                          select a).GroupBy(m => m.PostMonth).Select(l => l.Key).ToList();
                if (postMothList.MonthList != null && postMothList.MonthList.Any())
                {
                    postMothList.MonthList.Sort();
                    if (month != null)
                        postMonth = month.Value;
                    else
                        postMonth = postMothList.MonthList.LastOrDefault();
                }
                ViewBag.PostMonth = postMonth;

                // get main list of articles
                postMothList.PostList = (from a in articleListDefault
                                         where a.PostYear == postYear && a.PostMonth == postMonth
                                         select a).ToPagedList(pageNumber, pageSize);

                var yesterday = DateTime.Now.AddDays(-1).Date;
                var yesterdayEnd = DateTime.Today.Date;
                postMothList.MostViewTopicList = from p in memberContext.PopularTopicsAggregate
                                                 join t in memberContext.TopicMaster on p.TopicID equals t.TopicID
                                                 where p.TargetDate >= yesterday && p.TargetDate < yesterdayEnd
                                                 orderby p.Views descending
                                                 select t;
                return View(postMothList);
            }
            return View();
        }
Example #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="newsClassID"> wrong paramesster name : should be topicId</param>
        /// <param name="contributeID"></param>
        /// <param name="page"></param>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        public ActionResult SearchByCategory(int? newsClassID, long? contributeID, int? page, int? year, int? month)
        {
            //#1295対応 Route5_3で呼ばれたとき(contributeIDあり)は新規のURLに301リダイレクト
            //return RedirectToActionPermanent("Show", "Splg.Controllers.UserArticle", new { area = "", contributeID = contributeID });

            ViewBag.pageNO = "5-3";
            long memberID = 0;
            string email = string.Empty;
            string username = string.Empty;
            if (Session["CurrentUser"] != null)
            {
                memberID = Convert.ToInt64(Session["CurrentUser"].ToString());
                email = memberContext.Member.SingleOrDefault(m => m.MemberId == memberID).Mail;
                username = memberContext.Member.SingleOrDefault(m => m.MemberId == memberID).Nickname;
                ViewBag.UserName = username;
            }
            string topicName = memberContext.TopicMaster.SingleOrDefault(t => t.TopicID == newsClassID.Value).TopicName;
            if (newsClassID != null && contributeID != null)
            {
                var article = (from con in memberContext.Contribution
                               join conQuot in memberContext.ContributionQuotOrg on con.ContributeId equals conQuot.ContributeId
                               join quotTopic in memberContext.QuotTopic on conQuot.ContributeId equals quotTopic.ContributeID
                               join m in memberContext.Member on con.MemberId equals m.MemberId
                               join tm in memberContext.TopicMaster on quotTopic.TopicID equals tm.TopicID
                               where quotTopic.TopicID == newsClassID.Value && con.ContributeId == contributeID
                               select new UserArticleInfoViewModel
                               {
                                   SportID = tm.SportID,
                                   ContributeId = con.ContributeId,
                                   Title = con.Title,
                                   Body = con.Body,
                                   ImageLink = con.ContributedPicture,
                                   ContributeDate = con.ContributeDate.Value,
                                   ModifiedDate = con.ModifiedDate,
                                   MemberId = con.MemberId,
                                   TopicID = quotTopic.TopicID,
                                   NewsClassId = conQuot.NewsClassId,
                                   QuoteUniqueId1 = conQuot.QuoteUniqueId1,
                                   QuoteUniqueId2 = conQuot.QuoteUniqueId2,
                                   QuoteUniqueId3 = conQuot.QuoteUniqueId3,
                                   Status = conQuot.Status,
                                   Nickname = m.Nickname,
                                   ProfileImage = m.ProfileImg
                               }).SingleOrDefault();
                if (article != null)
                {
                    if (article.Status == 1)
                    {
                        article = AppliedDetailContent(article);
                    }
                    //(from quotTopic in memberContext.QuotTopic
                    //                   join topicMST in memberContext.TopicMaster on quotTopic.TopicID equals topicMST.TopicID
                    //                   where quotTopic.ContributeID == contributeID
                    //                   select new RelatedTopicViewModel
                    //                   {
                    //                       TopicId = quotTopic.TopicID,
                    //                       TopicName = topicMST.TopicName,
                    //                       TopicURL = topicMST.JumpUrl
                    //                   }).ToList<RelatedTopicViewModel>();
                    var articleListDefault = PostedController.GetRecentPosts(8, newsClassID.Value);
                    //articleListDefault = PostedController.GetRecentPosts(7, newsClassID.Value);
                    article.RightNewsestPosts = PostedController.GetRecentPosts(10, Convert.ToInt32(article.MemberId));
                    if (Session["CurrentUser"] != null)
                    {
                        int thisYear = DateTime.Now.Year;
                        int thisMonth = DateTime.Now.Month;

                        string query = "SELECT MemberID," +
                                        "       ISNULL(SUM(PayOffPoints), 0) AS PayOffPoints," +
                                        "       ISNULL(SUM(fundspoint), 0) AS FundsPoint," +
                                        "       ISNULL(SUM(possesionpoint), 0) AS PossesionPoint," +
                                        "       MAX(ExpectPoint_CreatedDate) AS LastExpectedPointDate " +
                                        "FROM [Splg].[Com].[Point] p " +
                                        "LEFT JOIN" +
                                        "  (SELECT PointID," +
                                        "          MAX(CreatedDate) AS ExpectPoint_CreatedDate" +
                                        "   FROM [Splg].[Com].[ExpectPoint]" +
                                        "   GROUP BY PointID) e ON p.PointID = e.PointID " +
                                        "WHERE p.PayOffFlg = '1'" +
                                        "  AND p.GiveTargetYear =  " + thisYear +
                                        "  AND p.GiveTargetMonth = " + thisMonth +
                                        " GROUP BY p.memberid";

                        var pointDatas = memberContext.Database.SqlQuery<FollowerMemberForUser>(@query).ToList<FollowerMemberForUser>();

                        article.FollowedUserInfo = (from m in memberContext.Member
                                                    from f2 in memberContext.FollowList.Where(x => x.MemberID == article.MemberId && x.FollowerMemberID == memberID).DefaultIfEmpty()
                                                    where m.MemberId == article.MemberId
                                                    select new FollowerMemberForUser
                                                    {
                                                        MemberId = m.MemberId,
                                                        Nickname = m.Nickname,
                                                        ProfileImg = m.ProfileImg,
                                                        IsFollowing = (f2.MemberID != null),
                                                    }).FirstOrDefault();
                        if (pointDatas != null)
                        {
                            var p = pointDatas.SingleOrDefault(x => x.MemberId == article.MemberId);
                            if (p != null && p.MemberId > 0)
                            {
                                article.FollowedUserInfo.PayOffPoints = p.PayOffPoints;
                                article.FollowedUserInfo.FundsPoint = p.FundsPoint;
                                article.FollowedUserInfo.PossesionPoint = p.PossesionPoint;
                                article.FollowedUserInfo.LastExpectedPointDate = p.LastExpectedPointDate;
                            }
                        }
                    }
                    article.RelatedPostList = (from ar in articleListDefault
                                               where ar.ContributeId != contributeID.Value
                                               orderby ar.ContributeDate descending
                                               select ar).Take(10);
                    ViewBag.TopicID = newsClassID.Value;
                    if (article != null && contributeID != null)
                    {
                        ViewBag.SportID = article.SportID;
                        SaveNewRecordToContributionReading(contributeID.Value);
                    }
                    return View("ViewArticleDetail", article);
                }
                return View("Error410");
            }
            else if (newsClassID != null && contributeID == null)
            {
                int topicID = newsClassID.Value;
                ViewBag.pageNO = "5-2";
                var articleListDefault = default(IEnumerable<PostedInfoViewModel>);
                if (Session["CurrentUser"] != null)
                {
                    articleListDefault = PostedController.GetRecentPosts(7, topicID);
                }
                else
                {
                    articleListDefault = PostedController.GetRecentPosts(8, topicID);
                }
                if (articleListDefault == null)
                {
                    ViewBag.SportID = 0;
                    ViewBag.TopicID = topicID;
                    return View("Index");
                }
                int pageNumber = (page ?? 1);
                int postYear = (year != null) ? year.Value : DateTime.Now.Year;
                int postMonth = DateTime.Now.Month;
                var spara = memberContext.SystemParamater.Find(1);
                int pageSize = 10;
                if (spara != null)
                    pageSize = Convert.ToInt32(spara.Spara);

                var postMothList = new UserArticleMonthListViewModel();
                postMothList.Year = postYear;
                postMothList.YearList = (from a in articleListDefault
                                         select a).GroupBy(m => m.PostYear).Select(l => l.Key).ToList();
                if (postMothList.YearList != null)
                    postMothList.YearList.Sort();
                postMothList.YearList.Sort();
                postMothList.MonthList = (from a in articleListDefault
                                          where a.PostYear == postYear
                                          select a).GroupBy(m => m.PostMonth).Select(l => l.Key).ToList();
                if (postMothList.MonthList != null && postMothList.MonthList.Any())
                {
                    postMothList.MonthList.Sort();
                    if (month != null)
                        postMonth = month.Value;
                    else
                        postMonth = postMothList.MonthList.LastOrDefault();
                }
                ViewBag.PostMonth = postMonth;

                // get main list of articles
                postMothList.PostList = (from a in articleListDefault
                                         where a.PostYear == postYear && a.PostMonth == postMonth
                                         select a).ToPagedList(pageNumber, pageSize);

                DateTime yesterday = DateTime.Now.AddDays(-1).Date;
                DateTime yesterdayEnd = DateTime.Today.Date;
                postMothList.MostViewTopicList = from p in memberContext.PopularTopicsAggregate
                                                 join t in memberContext.TopicMaster on p.TopicID equals t.TopicID
                                                 where p.TargetDate >= yesterday && p.TargetDate < yesterdayEnd
                                                 orderby p.Views descending
                                                 select t;

                ViewBag.SportID = 0;
                ViewBag.TopicID = topicID;
                return View("Index", postMothList);
            }
            return View("Error");
        }
Example #5
0
        public ActionResult ViewArticleBySport(int? sportID, int? page, int? year, int? month)
        {
            if (sportID.HasValue)
            {
                var articleListDefault = default(IEnumerable<PostedInfoViewModel>);
                if (Session["CurrentUser"] != null)
                {
                    articleListDefault = PostedController.GetRecentPosts(6, sportID.Value);
                }
                else
                {
                    articleListDefault = PostedController.GetRecentPosts(0, sportID.Value);
                }
                if (articleListDefault == null)
                {
                    ViewBag.SportID = sportID.Value;
                    return View("Index");
                }
                int pageNumber = (page ?? 1);
                int postYear = (year != null) ? year.Value : DateTime.Now.Year;
                int postMonth = DateTime.Now.Month;
                var spara = memberContext.SystemParamater.Find(1);
                int pageSize = 10;
                if (spara != null)
                    pageSize = Convert.ToInt32(spara.Spara);

                var postMothList = new UserArticleMonthListViewModel();
                postMothList.Year = postYear;
                postMothList.YearList = (from a in articleListDefault
                                         select a).GroupBy(m => m.PostYear).Select(l => l.Key).ToList();
                if (postMothList.YearList != null)
                    postMothList.YearList.Sort();
                postMothList.YearList.Sort();
                postMothList.MonthList = (from a in articleListDefault
                                          where a.PostYear == postYear
                                          select a).GroupBy(m => m.PostMonth).Select(l => l.Key).ToList();
                if (postMothList.MonthList != null && postMothList.MonthList.Any())
                {
                    postMothList.MonthList.Sort();
                    if (month != null)
                        postMonth = month.Value;
                    else
                        postMonth = postMothList.MonthList.LastOrDefault();
                }
                ViewBag.PostMonth = postMonth;

                // get main list of articles
                postMothList.PostList = (from a in articleListDefault
                                         where a.PostYear == postYear && a.PostMonth == postMonth
                                         select a).ToPagedList(pageNumber, pageSize);

                DateTime yesterday = DateTime.Now.AddDays(-1).Date;
                DateTime yesterdayEnd = DateTime.Today.Date;
                postMothList.MostViewTopicList = from p in memberContext.PopularTopicsAggregate
                                                 join t in memberContext.TopicMaster on p.TopicID equals t.TopicID
                                                 where p.TargetDate >= yesterday && p.TargetDate < yesterdayEnd
                                                 orderby p.Views descending
                                                 select t;

                ViewBag.SportID = sportID.Value;
                return View("Index", postMothList);
            }

            return View("Error");
        }