Пример #1
0
        public ActionResult Home()
        {
            mu = Membership.GetUser();

            if (mu == null)
            {
                return RedirectToAction("LogOff");
            }

            ua = new UserAccount(Convert.ToInt32(mu.ProviderUserKey));

            ViewBag.CurrentUser = ua.ToUnorderdListItem;

            StatusUpdates preFilter = new StatusUpdates();

            preFilter.GetStatusUpdatesPageWise(1, pageSize);

            StatusUpdates sus = new StatusUpdates();

            foreach (BootBaronLib.AppSpec.DasKlub.BOL.StatusUpdate su1
                in preFilter)
            {
                if (!BootBaronLib.AppSpec.DasKlub.BOL.BlockedUser.IsBlockingUser(ua.UserAccountID, su1.UserAccountID))
                {
                    sus.Add(su1);
                }
            }

            sus.IncludeStartAndEndTags = false;
            ViewBag.StatusUpdateList = string.Format(@"<ul id=""status_update_list_items"">{0}</ul>", sus.ToUnorderdList);

            StatusUpdateNotifications suns = new StatusUpdateNotifications();
            suns.GetStatusUpdateNotificationsForUser(ua.UserAccountID);

            if (suns.Count > 0)
            {
                suns.Sort(delegate(StatusUpdateNotification p1, StatusUpdateNotification p2)
                {
                    return p1.CreateDate.CompareTo(p2.CreateDate);
                });

                ViewBag.Notifications = suns;

                foreach (StatusUpdateNotification sun1 in suns)
                {
                    sun1.IsRead = true;
                    sun1.Update();
                }
            }

            StatusUpdates applauseResult = new StatusUpdates();
            applauseResult.GetMostAcknowledgedStatus(7, 'A');
            if (applauseResult.Count > 0)
            {
                ViewBag.MostApplauded = applauseResult;
            }

            StatusUpdate beatDownResult = new BootBaronLib.AppSpec.DasKlub.BOL.StatusUpdate();
            beatDownResult = new StatusUpdate();
            beatDownResult.GetMostAcknowledgedStatus(7, 'B');

            bool isAlreadyApplauded = false;

            if (beatDownResult.StatusUpdateID > 0)
            {
                foreach (StatusUpdate ssr1 in applauseResult)
                {
                    if (beatDownResult.StatusUpdateID == ssr1.StatusUpdateID)
                    {
                        isAlreadyApplauded = true;
                        break;
                    }
                }
            }

            if (!isAlreadyApplauded && beatDownResult.StatusUpdateID > 0)
            {
                ViewBag.MostBeatDown = beatDownResult;
            }

            //
            StatusUpdate commentResponse
            = new BootBaronLib.AppSpec.DasKlub.BOL.StatusUpdate(
            StatusComments.GetMostCommentedOnStatus(DateTime.UtcNow.AddDays(-7)));

            bool isAlreadyCommented = false;

            foreach (StatusUpdate ssr1 in applauseResult)
            {
                if (commentResponse.StatusUpdateID == ssr1.StatusUpdateID)
                {
                    isAlreadyCommented = true;
                }
            }

            if (!isAlreadyCommented && beatDownResult.StatusUpdateID != commentResponse.StatusUpdateID && commentResponse.StatusUpdateID > 0)
            {
                // only show if the most commented is different from most beat down or applauded
                ViewBag.MostCommented = commentResponse;
            }

            return View();
        }
Пример #2
0
        public ActionResult Home()
        {
            if (_mu == null)
            {
                return RedirectToAction("LogOff");
            }

            var uas = new UserAccounts();
            uas.GetNewestUsers();
            ViewBag.NewestUsers = uas.ToUnorderdList;

            _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey));

            ViewBag.CurrentUser = _ua.ToUnorderdListItem;

            var preFilter = new StatusUpdates();

            preFilter.GetStatusUpdatesPageWise(1, PageSize);

            var sus = new StatusUpdates();
            sus.AddRange(
                preFilter.Where(
                    su1 =>
                        !Lib.BOL.BlockedUser.IsBlockingUser(_ua.UserAccountID, su1.UserAccountID)));

            sus.IncludeStartAndEndTags = false;
            ViewBag.StatusUpdateList = string.Format(@"<ul id=""status_update_list_items"">{0}</ul>", sus.ToUnorderdList);

            var suns = new StatusUpdateNotifications();
            suns.GetStatusUpdateNotificationsForUser(_ua.UserAccountID);

            if (suns.Count > 0)
            {
                suns.Sort((p1, p2) => p1.CreateDate.CompareTo(p2.CreateDate));

                ViewBag.Notifications = suns;

                foreach (StatusUpdateNotification sun1 in suns)
                {
                    sun1.IsRead = true;
                    sun1.Update();
                }
            }

            var applauseResult = new StatusUpdates();
            applauseResult.GetMostAcknowledgedStatus(7, SiteEnums.AcknowledgementType.A);
            if (applauseResult.Count > 0)
            {
                ViewBag.MostApplauded = applauseResult;
            }

            var beatDownResult = new StatusUpdate();
            beatDownResult.GetMostAcknowledgedStatus(7, SiteEnums.AcknowledgementType.B);

            bool isAlreadyApplauded = false;

            if (beatDownResult.StatusUpdateID > 0)
            {
                if (applauseResult.Any(ssr1 => beatDownResult.StatusUpdateID == ssr1.StatusUpdateID))
                {
                    isAlreadyApplauded = true;
                }
            }

            if (!isAlreadyApplauded && beatDownResult.StatusUpdateID > 0)
            {
                ViewBag.MostBeatDown = beatDownResult;
            }

            var commentResponse = new StatusUpdate(StatusComments.GetMostCommentedOnStatus(DateTime.UtcNow.AddDays(-7)));

            bool isAlreadyCommented = false;

            foreach (
                StatusUpdate ssr1 in applauseResult.Where(ssr1 => commentResponse.StatusUpdateID == ssr1.StatusUpdateID)
                )
            {
                isAlreadyCommented = true;
            }

            if (!isAlreadyCommented && beatDownResult.StatusUpdateID != commentResponse.StatusUpdateID &&
                commentResponse.StatusUpdateID > 0)
            {
                ViewBag.MostCommented = commentResponse;
            }

            if (TempData["user_error"] != null)
            {
                ViewBag.Error = TempData["user_error"];
            }

            return View();
        }