Ejemplo n.º 1
0
 public void UpdateStatus(StatusUpdates x)
 {
     ScoreManager.happiness += x.happy;
     ScoreManager.gold      += x.gold;
     ScoreManager.skill     += x.skill;
     ScoreManager.socialize += x.socialize;
 }
Ejemplo n.º 2
0
        public IList <StatusUpdateViewModel> GetStatusUpdates(int pageId)
        {
            var statusUpdates = StatusUpdates.Where(x => x.PageId == pageId).OrderByDescending(x => x.UpdateDate)
                                .ToList();

            return(statusUpdates.Select(x => StatusUpdateViewModel.FromModel(x)).ToList());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Run the application.
        /// </summary>
        public override BoolMessageItem Execute()
        {
            StatusUpdates.Update("startup", "starting", "application startup", DateTime.Now, DateTime.Now);
            StatusUpdates.Update("startup", "completed", "application startup", DateTime.Now, DateTime.Now);
            StatusUpdates.Update("executing", "executing", "app execution", DateTime.Now, DateTime.Now);

            return(BoolMessageItem.True);
        }
Ejemplo n.º 4
0
        /// <summary>Fire the Status update Event</summary>
        internal void onStatusUpdates(string message, XeroEventStatus status)
        {
            StatusEventArgs args = new StatusEventArgs()
            {
                MessageText = message, Status = status
            };

            StatusUpdates.SafeInvoke(this, args);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handle the "Logging" the starting of the method call before execution.
        /// </summary>
        /// <param name="methodName"></param>
        private void HandleStart(string methodName, DateTime startTime)
        {
            if (IsDecoratedWith("log"))
            {
                Logger.Info(string.Format("{0}.{1} : {2} at {3}", _appType.Name, methodName, "Started", startTime));
            }

            if (IsDecoratedWith("statusupdates"))
            {
                StatusUpdates.Update(methodName, StatusUpdateConstants.Started, "", startTime, startTime);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handle the "Logging" the starting of the method call before execution.
        /// </summary>
        /// <param name="methodName"></param>
        private void HandleEnd(string methodName, DateTime startTime)
        {
            // Time ended.
            DateTime endTime = DateTime.Now;

            if (IsDecoratedWith("log"))
            {
                Logger.Info(string.Format("{0}.{1} : {2} at {3}", _appType.Name, methodName, "Finished", endTime));
            }

            if (IsDecoratedWith("statusupdates"))
            {
                StatusUpdates.Update(methodName, StatusUpdateConstants.Completed, "", startTime, endTime);
            }
        }
Ejemplo n.º 7
0
        public ActionResult Detail(int photoItemID)
        {
            _pitm = new PhotoItem(photoItemID);

            if (_pitm.PhotoItemID == 0)
                return HttpNotFound();

            var sus = new StatusUpdates();

            var su = new StatusUpdate();

            su.GetStatusUpdateByPhotoID(photoItemID);

            su.PhotoDisplay = true;
            sus.Add(su);

            if (string.IsNullOrWhiteSpace(_pitm.Title))
            {
                _pitm.Title = String.Format("{0:u}", _pitm.CreateDate);
            }

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

            var pitm2 = new PhotoItem();

            pitm2.GetPreviousPhoto(_pitm.CreateDate);
            if (pitm2.PhotoItemID > 0)
            {
                pitm2.ShowTitle = false;
                pitm2.UseThumb = true;
                ViewBag.PreviousPhoto = pitm2;
            }

            pitm2 = new PhotoItem();
            pitm2.GetNextPhoto(_pitm.CreateDate);

            if (pitm2.PhotoItemID > 0)
            {
                pitm2.ShowTitle = false;
                pitm2.UseThumb = true;
                ViewBag.NextPhoto = pitm2;
            }

            return View(_pitm);
        }
Ejemplo n.º 8
0
        public JsonResult StatusUpdates(int pageNumber)
        {
            mu = Membership.GetUser();

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

            ViewBag.CurrentUser = ua.ToUnorderdListItem;

            StatusUpdates preFilter = new StatusUpdates();

            preFilter.GetStatusUpdatesPageWise(pageNumber, 5);

            StringBuilder sb = new StringBuilder();

            foreach (BootBaronLib.AppSpec.DasKlub.BOL.StatusUpdate cnt in preFilter)
            {
                sb.Append(cnt.ToUnorderdListItem);
            }

            return Json(new
            {
                ListItems = sb.ToString()
            });
        }
Ejemplo n.º 9
0
        public ActionResult StatusUpdate(int statusUpdateID)
        {
            StatusUpdate su = new StatusUpdate(statusUpdateID);
            su.PhotoDisplay = false;

            StatusUpdates sus = new StatusUpdates();
            sus.Add(su);

            sus.IncludeStartAndEndTags = false;
            ViewBag.StatusUpdateList = @"<ul id=""status_update_list_items"">" + sus.ToUnorderdList + @"</ul>";

            return View(su);
        }
Ejemplo n.º 10
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();
        }
Ejemplo n.º 11
0
        public ActionResult UserPhoto(string userName, int photoItemID)
        {
            _ua = new UserAccount(userName);

            ViewBag.UserName = _ua.UserName;

            _pitm = new PhotoItem(photoItemID);

            var sus = new StatusUpdates();

            var su = new StatusUpdate();

            su.GetStatusUpdateByPhotoID(photoItemID);

            su.PhotoDisplay = true;
            sus.Add(su);

            if (string.IsNullOrWhiteSpace(_pitm.Title))
            {
                _pitm.Title = String.Format("{0:u}", _pitm.CreateDate);
            }

            sus.IncludeStartAndEndTags = false;
            ViewBag.StatusUpdateList = @"<ul id=""status_update_list_items"">" + sus.ToUnorderdList + @"</ul>";

            var pitm2 = new PhotoItem();

            pitm2.GetPreviousPhotoForUser(_pitm.CreateDate, _ua.UserAccountID);
            if (pitm2.PhotoItemID > 0)
            {
                pitm2.IsUserPhoto = true;
                pitm2.ShowTitle = false;
                pitm2.UseThumb = true;
                ViewBag.PreviousPhoto = pitm2;
            }

            pitm2 = new PhotoItem();
            pitm2.GetNextPhotoForUser(_pitm.CreateDate, _ua.UserAccountID);

            if (pitm2.PhotoItemID <= 0) return View(_pitm);

            pitm2.IsUserPhoto = true;
            pitm2.ShowTitle = false;
            pitm2.UseThumb = true;
            ViewBag.NextPhoto = pitm2;

            return View(_pitm);
        }
Ejemplo n.º 12
0
        public JsonResult StatusUpdates(int pageNumber)
        {
            if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey));

            ViewBag.CurrentUser = _ua.ToUnorderdListItem;

            var preFilter = new StatusUpdates();

            preFilter.GetStatusUpdatesPageWise(pageNumber, 5);

            var sb = new StringBuilder();

            foreach (StatusUpdate cnt in preFilter)
            {
                sb.Append(cnt.ToUnorderdListItem);
            }

            return Json(new
            {
                ListItems = sb.ToString()
            });
        }
Ejemplo n.º 13
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();
        }
Ejemplo n.º 14
0
        public void ProcessRequest(HttpContext context)
        {
            if (string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()]))
                return;

            var ptyc = (SiteEnums.QueryStringNames) Enum.Parse(typeof (SiteEnums.QueryStringNames),
                context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()]);

            MembershipUser mu;

            switch (ptyc)
            {
                case SiteEnums.QueryStringNames.status_update:

                    #region status_update

                    string key = context.Request.QueryString[SiteEnums.QueryStringNames.status_update_id.ToString()];

                    if (string.IsNullOrEmpty(key))
                    {
                        key =
                            context.Request.QueryString[
                                SiteEnums.QueryStringNames.most_applauded_status_update_id.ToString()];
                    }

                    int statusUpdateID = Convert.ToInt32(key);

                    StatusUpdate statup;

                    if (
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()]))
                    {
                        mu = MembershipWrapper.GetUser();

                        if (mu == null) return;
                        var ack = new Acknowledgement
                        {
                            CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey),
                            UserAccountID = Convert.ToInt32(mu.ProviderUserKey),
                            AcknowledgementType = Convert.ToChar(
                                context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()]),
                            StatusUpdateID = statusUpdateID
                        };

                        statup = new StatusUpdate(statusUpdateID);

                        if (!Acknowledgement.IsUserAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)))
                        {
                            ack.Create();

                            var sun = new StatusUpdateNotification();

                            if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString()))
                            {
                                sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID,
                                    SiteEnums.ResponseType.A);
                            }

                            if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID)
                            {
                                sun.UserAccountID = statup.UserAccountID;

                                SiteEnums.ResponseType rspType;

                                if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString()))
                                {
                                    rspType = SiteEnums.ResponseType.A;
                                    sun.ResponseType = Convert.ToChar(rspType.ToString());
                                }
                                else
                                {
                                    rspType = SiteEnums.ResponseType.B;
                                    sun.ResponseType = Convert.ToChar(rspType.ToString());
                                }

                                sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey);

                                if (sun.StatusUpdateNotificationID == 0)
                                {
                                    sun.IsRead = false;
                                    sun.Create();
                                }
                                else
                                {
                                    sun.IsRead = false;
                                    sun.Update();
                                }

                                SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey), rspType,
                                    sun.StatusUpdateID);
                            }

                            context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}",
                                HttpUtility.HtmlEncode(statup.StatusAcknowledgements)));
                        }
                        else
                        {
                            // reverse

                            ack.GetAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey));

                            ack.Delete();

                            // TODO: DELETE NOTIFICATION

                            context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}",
                                HttpUtility.HtmlEncode(statup.StatusAcknowledgements)));
                        }
                    }
                    else if (
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[
                                SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()]))
                    {
                        mu = MembershipWrapper.GetUser();

                        if (mu == null) return;
                        var ack = new StatusCommentAcknowledgement
                        {
                            CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey),
                            UserAccountID = Convert.ToInt32(mu.ProviderUserKey),
                            AcknowledgementType = Convert.ToChar(
                                context.Request.QueryString[
                                    SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()]),
                            StatusCommentID = statusUpdateID
                        };

                        var statcomup = new StatusComment(statusUpdateID);

                        statup = new StatusUpdate(statcomup.StatusUpdateID);

                        if (!StatusCommentAcknowledgement.IsUserCommentAcknowledgement(statcomup.StatusCommentID,
                            Convert.ToInt32(
                                mu.ProviderUserKey)))
                        {
                            ack.Create();

                            var sun = new StatusUpdateNotification();

                            sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID,
                                statcomup.StatusUpdateID,
                                ack.AcknowledgementType ==
                                Convert.ToChar(
                                    SiteEnums.ResponseType.A.ToString())
                                    ? SiteEnums.ResponseType.A
                                    : SiteEnums.ResponseType.B);

                            if (Convert.ToInt32(mu.ProviderUserKey) != statcomup.UserAccountID)
                            {
                                sun.UserAccountID = statcomup.UserAccountID;

                                SiteEnums.ResponseType rspType;

                                if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString()))
                                {
                                    rspType = SiteEnums.ResponseType.A;
                                    sun.ResponseType = Convert.ToChar(rspType.ToString());
                                }
                                else
                                {
                                    rspType = SiteEnums.ResponseType.B;
                                    sun.ResponseType = Convert.ToChar(rspType.ToString());
                                }

                                if (sun.StatusUpdateNotificationID == 0)
                                {
                                    sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                    sun.IsRead = false;
                                    sun.Create();
                                }
                                else
                                {
                                    sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                    sun.IsRead = false;
                                    sun.Update();
                                }

                                SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey), rspType,
                                    sun.StatusUpdateID);
                            }

                            context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode(
                                statcomup.StatusCommentAcknowledgementsOptions)));
                        }
                        else
                        {
                            // reverse

                            ack.GetCommentAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey));

                            ack.Delete();
                            // TODO: DELETE NOTIFICATION

                            context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode(
                                statcomup.StatusCommentAcknowledgementsOptions)));
                        }
                    }
                    else if (
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) &&
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()])
                        )
                    {
                        mu = MembershipWrapper.GetUser();

                        if (mu == null) return;

                        var statCom = new StatusComment
                        {
                            CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey),
                            Message = HttpUtility.HtmlEncode(
                                context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]),
                            StatusUpdateID = statusUpdateID,
                            UserAccountID = Convert.ToInt32(mu.ProviderUserKey)
                        };

                        // TODO: CHECK IF THERE IS A RECENT MESSAGE THAT IS THE SAME
                        if (statCom.StatusCommentID != 0) return;
                        //BUG: THERE IS AN EVENT HANDLER THAT HAS QUEUED UP TOO MANY
                        var suLast = new StatusUpdate();
                        suLast.GetMostRecentUserStatus(Convert.ToInt32(mu.ProviderUserKey));

                        if (suLast.Message.Trim() != statCom.Message.Trim() ||
                            (suLast.Message.Trim() == statCom.Message.Trim() &&
                             suLast.StatusUpdateID != statCom.StatusUpdateID))
                        {
                            statCom.Create();
                        }

                        statup = new StatusUpdate(statusUpdateID);

                        // create a status update notification for the post maker and all commenters
                        StatusUpdateNotification sun;

                        if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID)
                        {
                            sun = new StatusUpdateNotification();

                            sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID,
                                statusUpdateID,
                                SiteEnums.ResponseType.C);

                            if (sun.StatusUpdateNotificationID == 0)
                            {
                                sun.ResponseType = Convert.ToChar(SiteEnums.ResponseType.C.ToString());
                                sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                sun.IsRead = false;
                                sun.StatusUpdateID = statup.StatusUpdateID;
                                sun.UserAccountID = statup.UserAccountID;
                                sun.Create();
                            }
                            else
                            {
                                sun.IsRead = false;
                                sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                sun.Update();
                            }

                            SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey),
                                SiteEnums.ResponseType.C, sun.StatusUpdateID);
                        }

                        var statComs = new StatusComments();

                        statComs.GetAllStatusCommentsForUpdate(statusUpdateID);

                        foreach (StatusComment sc1 in statComs)
                        {
                            sun = new StatusUpdateNotification();

                            sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID,
                                statusUpdateID,
                                SiteEnums.ResponseType.C);

                            if (Convert.ToInt32(mu.ProviderUserKey) == sc1.UserAccountID ||
                                Convert.ToInt32(mu.ProviderUserKey) == statup.UserAccountID) continue;

                            if (sun.StatusUpdateNotificationID == 0)
                            {
                                sun.IsRead = false;
                                sun.StatusUpdateID = statusUpdateID;
                                sun.UserAccountID = sc1.UserAccountID;
                                sun.Create();
                            }
                            else
                            {
                                sun.IsRead = false;
                                sun.Update();
                            }
                        }
                        context.Response.Write(@"{""StatusAcks"": """ + @"""}");
                    }
                    else if (
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) &&
                        context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "P"
                        )
                    {
                        // delete post
                        statup = new StatusUpdate(statusUpdateID);

                        StatusUpdateNotifications.DeleteNotificationsForStatusUpdate(statup.StatusUpdateID);
                        Acknowledgements.DeleteStatusAcknowledgements(statup.StatusUpdateID);

                        var statComs = new StatusComments();
                        statComs.GetAllStatusCommentsForUpdate(statup.StatusUpdateID);

                        foreach (StatusComment sc1 in statComs)
                        {
                            StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements(
                                sc1.StatusCommentID);
                        }
                        StatusComments.DeleteStatusComments(statup.StatusUpdateID);

                        statup.Delete();

                        if (statup.PhotoItemID != null)
                        {
                            var pitm = new PhotoItem(Convert.ToInt32(statup.PhotoItemID));

                            var s3 = new S3Service
                            {
                                AccessKeyID = AmazonCloudConfigs.AmazonAccessKey,
                                SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey
                            };

                            if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw))
                            {
                                s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw);
                            }

                            if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard))
                            {
                                s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard);
                            }

                            if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb))
                            {
                                s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb);
                            }

                            pitm.Delete();
                        }
                        context.Response.Write(@"{""StatusAcks"": """ + @"""}");
                    }
                    else if (
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) &&
                        context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] ==
                        "C"
                        )
                    {
                        // delete comment

                        var statCom = new StatusComment(
                            Convert.ToInt32(
                                context.Request.QueryString[
                                    SiteEnums.QueryStringNames.status_com_id.ToString()]));

                        StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements(
                            statCom.StatusCommentID);

                        statCom.Delete();

                        context.Response.Write(string.Format(@"{{""StatusUpdateID"": ""{0}""}}", statCom.StatusUpdateID));
                    }
                    else if (!string.IsNullOrEmpty(
                        context.Request.QueryString[SiteEnums.QueryStringNames.all_comments.ToString()]))
                    {
                        mu = MembershipWrapper.GetUser();

                        if (mu == null) return;

                        var preFilter = new StatusComments();

                        preFilter.GetAllStatusCommentsForUpdate(statusUpdateID);

                        var statComs = new StatusComments();
                        statComs.AddRange(
                            preFilter.Where(
                                su1 =>
                                    !BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID)));

                        statComs.IncludeStartAndEndTags = true;

                        var sb = new StringBuilder(100);

                        sb.Append(statComs.ToUnorderdList);

                        context.Response.Write(string.Format(@"{{""StatusComs"": ""{0}""}}",
                            HttpUtility.HtmlEncode(sb.ToString())));
                    }
                    else if (!string.IsNullOrEmpty(
                        context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()]))
                    {
                        int pcount =
                            Convert.ToInt32(
                                context.Request.QueryString[
                                    SiteEnums.QueryStringNames.comment_page.ToString()]);

                        var statups = new StatusUpdates();

                        pcount = pcount + 10;

                        var preFilter = new StatusUpdates();

                        preFilter.GetStatusUpdatesPageWise(pcount, 1);

                        mu = MembershipWrapper.GetUser();

                        statups.AddRange(
                            preFilter.Where(
                                su1 =>
                                    mu != null &&
                                    !BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID)));

                        statups.IncludeStartAndEndTags = false;

                        context.Response.Write(string.Format(@"{{""StatusUpdates"": ""{0}""}}",
                            HttpUtility.HtmlEncode(statups.ToUnorderdList)));
                    }

                    #endregion

                    break;
                case SiteEnums.QueryStringNames.begin_playlist:

                    #region begin_playlist

                    context.Response.Write(
                        PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[
                            SiteEnums.QueryStringNames.playlist.ToString()])));

                    #endregion

                    break;
                case SiteEnums.QueryStringNames.menu:

                    #region menu

                    mu = MembershipWrapper.GetUser();

                    int userCountChat = 0;
                    int userMessages = 0;
                    int unconfirmedUsers = 0;
                    int notifications = 0;

                    if (mu != null)
                    {
                        // log off users who are offline

                        var uasOffline = new UserAccounts();
                        uasOffline.GetWhoIsOffline(true);

                        foreach (UserAccount uaoff1 in uasOffline)
                        {
                            var cru = new ChatRoomUser();
                            cru.GetChatRoomUserByUserAccountID(uaoff1.UserAccountID);

                            if (cru.ChatRoomUserID > 0)
                            {
                                cru.DeleteChatRoomUser();
                            }

                            var offlineUser = new UserAccount(uaoff1.UserAccountID);
                            offlineUser.RemoveCache();
                        }

                        userCountChat = ChatRoomUsers.GetChattingUserCount();

                        userMessages = DirectMessages.GetDirectMessagesToUserCount(mu);
                        unconfirmedUsers =
                            UserConnections.GetCountUnconfirmedConnections(Convert.ToInt32(mu.ProviderUserKey));
                    }

                    // get users online
                    int onlineUsers = UserAccounts.GetOnlineUserCount();

                    if (mu != null)
                    {
                        notifications =
                            StatusUpdateNotifications.GetStatusUpdateNotificationCountForUser(
                                Convert.ToInt32(mu.ProviderUserKey));
                    }

                    string timedMessge = string.Format(
                        @"{{""UserCountChat"": ""{0}"",
               ""UserMessages"": ""{1}"",
               ""OnlineUsers"": ""{2}"",
               ""Notifications"": ""{3}"",
               ""UnconfirmedUsers"": ""{4}""}}", userCountChat, userMessages, onlineUsers, notifications,
                        unconfirmedUsers);

                    context.Response.Write(timedMessge);

                    #endregion

                    break;
                case SiteEnums.QueryStringNames.random:

                    #region random

                    if (
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]))
                    {
                        context.Response.Write(Video.GetRandomJSON(
                            context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]));
                    }
                    else
                    {
                        context.Response.Write(Video.GetRandomJSON());
                    }

                    #endregion

                    break;
                case SiteEnums.QueryStringNames.video_playlist:

                    #region video_playlist

                    if (!string.IsNullOrEmpty(
                        context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]))
                    {
                        context.Response.Write(
                            PlaylistVideo.GetNextVideo(
                                Convert.ToInt32(
                                    context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]),
                                context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]));
                    }
                    else if (
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()]))
                    {
                        context.Response.Write(
                            PlaylistVideo.GetFirstVideo(
                                Convert.ToInt32(
                                    context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()])));
                    }
                    else
                    {
                        context.Response.Write(
                            PlaylistVideo.CurrentVideoInPlaylist(
                                Convert.ToInt32(
                                    context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()])
                                ));
                    }

                    #endregion

                    break;
                case SiteEnums.QueryStringNames.video:

                    #region video

                    var vid = new Video("YT", context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()]);

                    VideoLog.AddVideoLog(vid.VideoID, context.Request.UserHostAddress);

                    context.Response.Write(
                        Video.GetVideoJSON(context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()]));

                    #endregion

                    break;

                case SiteEnums.QueryStringNames.playlist:

                    #region playlist

                    if (!string.IsNullOrEmpty(
                        context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]))
                    {
                        context.Response.Write(
                            PlaylistVideo.GetNextVideo(
                                Convert.ToInt32(
                                    context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]),
                                context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]));
                    }
                    else if (
                        !string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()]))
                    {
                        context.Response.Write(
                            PlaylistVideo.GetFirstVideo(
                                Convert.ToInt32(
                                    context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()])));
                    }
                    else
                    {
                        context.Response.Write(
                            PlaylistVideo.CurrentVideoInPlaylist(
                                Convert.ToInt32(
                                    context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()])
                                ));
                    }

                    #endregion

                    break;
            }
        }
Ejemplo n.º 15
0
        public void ProcessRequest(HttpContext context)
        {
            //        context.Response.ContentType = "text/plain";

               //    context.Response.CacheControl = "no-cache";

               // context.Response.AddHeader("Pragma", "no-cache");

               // //context.Response.AddHeader("Pragma", "no-store");

               // //context.Response.AddHeader("cache-control", "no-cache");

               //context.Response.Cache.SetCacheability(HttpCacheability.NoCache);

               // context.Response.Cache.SetNoServerCaching();

            if (string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()])) return;

            SiteEnums.QueryStringNames ptyc = (SiteEnums.QueryStringNames)Enum.Parse(typeof(SiteEnums.QueryStringNames),
                context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()]);

              //  Dictionary<string, Subgurim.Chat.Usuario> usrrs = null;
            StringBuilder sb = null;
            MembershipUser mu = null;

            switch (ptyc)
            {
                case SiteEnums.QueryStringNames.status_update:
                    #region status_update

                    string key = context.Request.QueryString[SiteEnums.QueryStringNames.status_update_id.ToString()];

                    if (string.IsNullOrEmpty(key))
                    {
                        key = context.Request.QueryString[SiteEnums.QueryStringNames.most_applauded_status_update_id.ToString()];
                    }

                    int statusUpdateID = Convert.ToInt32(key);

                    StatusUpdate statup = null;

                    if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()]))
                    {
                        mu = Membership.GetUser();

                        Acknowledgement ack = new Acknowledgement();

                        ack.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                        ack.UserAccountID = Convert.ToInt32(mu.ProviderUserKey);
                        ack.AcknowledgementType = Convert.ToChar(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()]);
                        ack.StatusUpdateID = statusUpdateID;

                        statup = new StatusUpdate(statusUpdateID);

                        if (!Acknowledgement.IsUserAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)))
                        {
                            ack.Create();

                            StatusUpdateNotification sun = new StatusUpdateNotification();

                            if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString()))
                            {
                                //  sun.GetStatusUpdateNotificationForUserStatus(Convert.ToInt32(mu.ProviderUserKey), statusUpdateID, SiteEnums.ResponseType.A);
                                sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.A);
                            }
                            else if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.B.ToString()))
                            {
                                //sun.GetStatusUpdateNotificationForUserStatus(Convert.ToInt32(mu.ProviderUserKey), statusUpdateID, SiteEnums.ResponseType.B);
                                sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.B);
                            }

                            if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID)
                            {
                                sun.UserAccountID = statup.UserAccountID;

                                SiteEnums.ResponseType rspType = SiteEnums.ResponseType.U;

                                if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString()))
                                {
                                    rspType = SiteEnums.ResponseType.A;
                                    sun.ResponseType = Convert.ToChar(rspType.ToString());
                                }
                                else
                                {
                                    rspType = SiteEnums.ResponseType.B;
                                    sun.ResponseType = Convert.ToChar(rspType.ToString());
                                }

                                sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey);

                                if (sun.StatusUpdateNotificationID == 0)
                                {
                                    sun.IsRead = false;
                                    sun.Create();
                                }
                                else
                                {
                                    sun.IsRead = false;
                                    sun.Update();
                                }

                                SendNotificationEmail(statup.UserAccountID, rspType, sun.StatusUpdateID);
                            }

                            context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statup.StatusAcknowledgements) + @"""}");
                        }
                        else
                        {
                            // reverse

                            ack.GetAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey));

                            ack.Delete();

                            // TODO: DELETE NOTIFICATION

                            context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statup.StatusAcknowledgements) + @"""}");
                        }
                    }
                    else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()]))
                    {
                        mu = Membership.GetUser();

                        StatusCommentAcknowledgement ack = new StatusCommentAcknowledgement();

                        ack.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                        ack.UserAccountID = Convert.ToInt32(mu.ProviderUserKey);
                        ack.AcknowledgementType = Convert.ToChar(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()]);
                        ack.StatusCommentID = statusUpdateID; // this is really the commentID (or should be)

                        StatusComment statcomup = new StatusComment(statusUpdateID);

                        statup = new StatusUpdate(statcomup.StatusUpdateID);

                        if (!StatusCommentAcknowledgement.IsUserCommentAcknowledgement(statcomup.StatusCommentID, Convert.ToInt32(mu.ProviderUserKey)))
                        {
                            ack.Create();

                            StatusUpdateNotification sun = new StatusUpdateNotification();

                            if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString()))
                            {
                                sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID, statcomup.StatusUpdateID, SiteEnums.ResponseType.A);
                            }
                            else
                            {
                                sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID, statcomup.StatusUpdateID, SiteEnums.ResponseType.B);
                            }

                            if (Convert.ToInt32(mu.ProviderUserKey) != statcomup.UserAccountID)
                            {
                                sun.UserAccountID = statcomup.UserAccountID;

                                SiteEnums.ResponseType rspType = SiteEnums.ResponseType.U;

                                if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString()))
                                {
                                    rspType = SiteEnums.ResponseType.A;
                                    sun.ResponseType = Convert.ToChar(rspType.ToString());
                                }
                                else
                                {
                                    rspType = SiteEnums.ResponseType.B;
                                    sun.ResponseType = Convert.ToChar(rspType.ToString());
                                }

                                if (sun.StatusUpdateNotificationID == 0)
                                {
                                    sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                    sun.IsRead = false;
                                    sun.Create();
                                }
                                else
                                {
                                    sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                    sun.IsRead = false;
                                    sun.Update();
                                }

                                SendNotificationEmail(statup.UserAccountID, rspType, sun.StatusUpdateID);
                            }

                            context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statcomup.StatusCommentAcknowledgementsOptions) + @"""}");
                        }
                        else
                        {
                            // reverse

                            ack.GetCommentAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey));

                            ack.Delete();
                            // TODO: DELETE NOTIFICATION

                            context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statcomup.StatusCommentAcknowledgementsOptions) + @"""}");
                        }
                    }
                    else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) &&
                        !string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()])
                        )
                    {
                        mu = Membership.GetUser();

                        if (mu == null) return;

                        StatusComment statCom = new StatusComment();
                        statCom.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                        statCom.Message = HttpUtility.HtmlEncode(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]);
                        statCom.StatusUpdateID = statusUpdateID;
                        statCom.UserAccountID = Convert.ToInt32(mu.ProviderUserKey);

                        //statCom.GetStatusCommentMessage(); // ? ignore this duplicate now

                        // TODO: CHECK IF THERE IS A RECENT MESSAGE THAT IS THE SAME
                        if (statCom.StatusCommentID == 0)
                        {
                            //BUG: THERE IS AN EVENT HANDLER THAT HAS QUEUED UP TOO MANY
                            StatusUpdate suLast = new StatusUpdate();
                            suLast.GetMostRecentUserStatus(Convert.ToInt32(mu.ProviderUserKey));

                            if (suLast.Message.Trim() != statCom.Message.Trim() || (suLast.Message.Trim() == statCom.Message.Trim() && suLast.StatusUpdateID != statCom.StatusUpdateID))
                            {
                                statCom.Create();
                            }

                            statup = new StatusUpdate(statusUpdateID);

                            // create a status update notification for the post maker and all commenters
                            StatusUpdateNotification sun = null;

                            if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID)
                            {
                                sun = new StatusUpdateNotification();

                                sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C);

                                if (sun.StatusUpdateNotificationID == 0)
                                {
                                    sun.ResponseType = Convert.ToChar(SiteEnums.ResponseType.C.ToString());
                                    sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                    sun.IsRead = false;
                                    sun.StatusUpdateID = statup.StatusUpdateID;
                                    sun.UserAccountID = statup.UserAccountID;
                                    sun.Create();
                                }
                                else
                                {
                                    sun.IsRead = false;
                                    sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey);
                                    sun.Update();
                                }

                                SendNotificationEmail(statup.UserAccountID, SiteEnums.ResponseType.C, sun.StatusUpdateID);
                            }

                            StatusComments statComs = new StatusComments();

                            statComs.GetAllStatusCommentsForUpdate(statusUpdateID);

                            foreach (StatusComment sc1 in statComs)
                            {
                                sun = new StatusUpdateNotification();

                                sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C);

                                if (Convert.ToInt32(mu.ProviderUserKey) == sc1.UserAccountID ||
                                    Convert.ToInt32(mu.ProviderUserKey) == statup.UserAccountID) continue;

                                if (sun.StatusUpdateNotificationID == 0)
                                {
                                    sun.IsRead = false;
                                    sun.StatusUpdateID = statusUpdateID;
                                    sun.UserAccountID = sc1.UserAccountID;
                                    sun.Create();
                                }
                                else
                                {
                                    sun.IsRead = false;
                                    sun.Update();
                                }
                            }
                            context.Response.Write(@"{""StatusAcks"": """ +  @"""}");
                        }
                    }
                    else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) &&
                         context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "P"
                        )
                    {
                        // delete post
                        statup = new StatusUpdate(statusUpdateID);

                        StatusUpdateNotifications.DeleteNotificationsForStatusUpdate(statup.StatusUpdateID);
                        Acknowledgements.DeleteStatusAcknowledgements(statup.StatusUpdateID);

                        StatusComments statComs = new StatusComments();
                        statComs.GetAllStatusCommentsForUpdate(statup.StatusUpdateID);

                        foreach (StatusComment sc1 in statComs)
                        {
                            StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements(sc1.StatusCommentID);
                        }
                        StatusComments.DeleteStatusComments(statup.StatusUpdateID);

                        statup.Delete();

                        if (statup.PhotoItemID != null)
                        {
                            PhotoItem pitm = new PhotoItem(Convert.ToInt32(statup.PhotoItemID));

                            S3Service s3 = new S3Service();

                            s3.AccessKeyID = AmazonCloudConfigs.AmazonAccessKey;
                            s3.SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey;

                            if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw))
                            {
                                s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw);
                            }

                            if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard))
                            {
                                s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard);
                            }

                            if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb))
                            {
                                s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb);
                            }

                            pitm.Delete();
                        }
                        context.Response.Write(@"{""StatusAcks"": """ + @"""}");
                    }
                    else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) &&
                             context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "C"
                            )
                    {
                        // delete comment

                        StatusComment statCom = new StatusComment(
                            Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.status_com_id.ToString()]));

                        StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements(statCom.StatusCommentID);

                        statCom.Delete();

                        context.Response.Write(@"{""StatusUpdateID"": """ + statCom.StatusUpdateID.ToString() + @"""}");
                    }
                    else if (!string.IsNullOrEmpty(
                        context.Request.QueryString[SiteEnums.QueryStringNames.all_comments.ToString()]))
                    {
                        mu = Membership.GetUser();

                        if (mu == null) return;

                        StatusComments preFilter = new StatusComments();

                        preFilter.GetAllStatusCommentsForUpdate(statusUpdateID);

                        StatusComments statComs = new StatusComments();

                        foreach (BootBaronLib.AppSpec.DasKlub.BOL.StatusComment su1 in preFilter)
                        {
                            if (!BootBaronLib.AppSpec.DasKlub.BOL.BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID))
                            {
                                statComs.Add(su1);
                            }
                        }

                        statComs.IncludeStartAndEndTags = true;

                        sb = new StringBuilder(100);

                        sb.Append(statComs.ToUnorderdList);

                        context.Response.Write(@"{""StatusComs"": """ + HttpUtility.HtmlEncode(sb.ToString()) + @"""}");
                    }
                    else if (!string.IsNullOrEmpty(
                            context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()]))
                    {
                        int pcount = Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()]);

                        StatusUpdates statups = new StatusUpdates();

                        pcount = pcount + 10;

                        StatusUpdates preFilter = new StatusUpdates();

                        preFilter.GetStatusUpdatesPageWise(pcount, 1);

                        StatusUpdates sus = new StatusUpdates();

                        mu = Membership.GetUser();

                        foreach (BootBaronLib.AppSpec.DasKlub.BOL.StatusUpdate su1
                            in preFilter)
                        {
                            if (!BootBaronLib.AppSpec.DasKlub.BOL.BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID))
                            {
                                statups.Add(su1);
                            }
                        }

                        statups.IncludeStartAndEndTags = false;

                        context.Response.Write(@"{""StatusUpdates"": """ + HttpUtility.HtmlEncode(statups.ToUnorderdList) + @"""}");
                    }

                    #endregion
                    break;
                case SiteEnums.QueryStringNames.begin_playlist:
                    #region begin_playlist
                    context.Response.Write(
                       PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[
                       SiteEnums.QueryStringNames.playlist.ToString()])));
                    #endregion
                    break;
                case SiteEnums.QueryStringNames.menu:
                    #region menu

                    mu = Membership.GetUser();

                    // menu updates

                    // get count in video room
                    int userCountChat = 0;

                    // get new mail
                    int userMessages = 0;

                    // get new users
                    int unconfirmedUsers = 0;

                    // status notifications
                    int notifications = 0;

                    if (mu != null)
                    {
                        // log off users who are offline

                        UserAccounts uasOffline = new UserAccounts();
                        uasOffline.GetWhoIsOffline(true);

                        UserAccount offlineUser = null;

                        foreach (UserAccount uaoff1 in uasOffline)
                        {
                            ChatRoomUser cru = new ChatRoomUser();
                            cru.GetChatRoomUserByUserAccountID(uaoff1.UserAccountID);

                            if (cru.ChatRoomUserID > 0)
                            {
                                cru.DeleteChatRoomUser();
                            }

                            offlineUser = new UserAccount(uaoff1.UserAccountID);
                            offlineUser.RemoveCache();
                        }

                        userCountChat = ChatRoomUsers.GetChattingUserCount();

                        userMessages = BootBaronLib.AppSpec.DasKlub.BOL.DirectMessages.GetDirectMessagesToUserCount(mu);
                        unconfirmedUsers = BootBaronLib.AppSpec.DasKlub.BOL.UserConnections.GetCountUnconfirmedConnections(Convert.ToInt32(mu.ProviderUserKey));
                    }

                    // get users online
                    int onlineUsers = UserAccounts.GetOnlineUserCount();

                    if (mu != null)
                    {
                        notifications = StatusUpdateNotifications.GetStatusUpdateNotificationCountForUser(Convert.ToInt32(mu.ProviderUserKey));
                    }

                    string timedMessge = string.Format(
            @"{{""UserCountChat"": ""{0}"",
               ""UserMessages"": ""{1}"",
               ""OnlineUsers"": ""{2}"",
               ""Notifications"": ""{3}"",
               ""UnconfirmedUsers"": ""{4}""}}",userCountChat,userMessages,onlineUsers,notifications,unconfirmedUsers);

                    context.Response.Write(timedMessge);

                    #endregion
                    break;
                case SiteEnums.QueryStringNames.random:
                    #region random
                    if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]))
                    {
                        context.Response.Write(Video.GetRandomJSON(
                            context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]));
                    }
                    else
                    {
                        context.Response.Write(Video.GetRandomJSON());
                    }

                    #endregion
                    break;
                case SiteEnums.QueryStringNames.video_playlist:
                    #region video_playlist
                    if (!string.IsNullOrEmpty(
               context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]))
                    {
                        context.Response.Write(
                            PlaylistVideo.GetNextVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]),
                            context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]));
                    }
                    else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()]))
                    {
                        context.Response.Write(
                          PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()])));
                    }
                    else
                    {
                        context.Response.Write(
                            PlaylistVideo.CurrentVideoInPlaylist(
                            Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()])
                            ));
                    }
                    #endregion
                    break;
                case SiteEnums.QueryStringNames.video:
                    #region video
                    Video vid = new Video("YT", context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()]);

                    VideoLog.AddVideoLog(vid.VideoID, context.Request.UserHostAddress);

                    context.Response.Write(Video.GetVideoJSON(context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()]));
                    #endregion
                    break;
                case SiteEnums.QueryStringNames.begindate:
                    #region begindate

                    //string[] dates = HttpUtility.UrlDecode(
                    //    context.Request.QueryString[SiteEnums.QueryStringNames.begindate.ToString()]
                    //    ).Split('G');

                    DateTime dtBegin = Convert.ToDateTime(context.Request.QueryString[SiteEnums.QueryStringNames.begindate.ToString()]);

                    dtBegin = new DateTime(dtBegin.Year, dtBegin.Month, 1);

                    DateTime dtEnd = dtBegin.AddMonths(1).AddDays(-1);
                    Events tds = new Events();

                    tds.GetEventsForLocation(
                          dtBegin, dtEnd,
                          context.Request.QueryString[SiteEnums.QueryStringNames.country_iso.ToString()],
                          context.Request.QueryString[SiteEnums.QueryStringNames.region.ToString()],
                          context.Request.QueryString[SiteEnums.QueryStringNames.city.ToString()]);

                    CalendarItems citms = GetCitms(tds, dtBegin, dtEnd, true);

                    //[ 100, 500, 300, 200, 400 ]
                    sb = new StringBuilder();

                    sb.Append("[");

                    int processed = 1;

                    foreach (CalendarItem ci1 in citms)
                    {
                        if (processed == citms.Count)
                        {
                            sb.Append(ci1.StartDate.Day);
                        }
                        else
                        {
                            sb.Append(ci1.StartDate.Day);
                            sb.Append(", ");
                        }

                        processed++;
                    }

                    sb.Append("]");

                    context.Response.Write(sb.ToString());
                    #endregion
                    break;
                case SiteEnums.QueryStringNames.playlist:
                    #region playlist

                    if (!string.IsNullOrEmpty(
                    context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]))
                    {
                        context.Response.Write(
                            PlaylistVideo.GetNextVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]),
                            context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()]));
                    }
                    else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()]))
                    {
                        context.Response.Write(
                          PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()])));
                    }
                    else
                    {
                        context.Response.Write(
                            PlaylistVideo.CurrentVideoInPlaylist(
                            Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()])
                            ));
                    }
                    #endregion
                    break;
                default:
                    // ?
                    break;

            }
        }