Example #1
0
        protected void btnUnlockVideo_Click(object sender, EventArgs e)
        {
            if (CurrentUserSession == null)
            {
                Response.Redirect("~/Registration.aspx");
                return;
            }

            if (CurrentUserSession.Credits - CurrentUserSession.BillingPlanOptions.CanViewUserVideos.Credits < 0)
            {
                Session["BillingPlanOption"] = CurrentUserSession.BillingPlanOptions.CanViewUserVideos;
                Response.Redirect("~/ManageProfile.aspx?sel=payment");
                return;
            }

            CurrentUserSession.Credits -= CurrentUserSession.BillingPlanOptions.CanViewUserVideos.Credits;
            CurrentUserSession.Update(true);

            CreditsHistory creditsHistory = new CreditsHistory(CurrentUserSession.Username);
            creditsHistory.Amount = CurrentUserSession.BillingPlanOptions.CanViewUserVideos.Credits;
            creditsHistory.Service = CreditsHistory.eService.ViewVideo;
            creditsHistory.Save();

            int id = GetIdFromVideoURL(VideoUploadUrl);
            UnlockedSection.UnlockSection(CurrentUserSession.Username, User.Username, UnlockedSection.SectionType.Video,
                                          id, DateTime.Now.AddDays(Config.Credits.VideoUnlockPeriod));

            pnlVideoUpload.Visible = true;
        }
Example #2
0
        protected void btnUnlockVideoStream_Click(object sender, EventArgs e)
        {
            if (CurrentUserSession == null)
            {
                Response.Redirect("~/Registration.aspx");
                return;
            }

            int credits = CurrentUserSession.BillingPlanOptions.CanViewStreamedVideo.Credits;
            if (CurrentUserSession.Credits - credits /*Config.Credits.CreditsForVideoStream*/ < 0)
            {
                Session["BillingPlanOption"] = CurrentUserSession.BillingPlanOptions.CanViewStreamedVideo;
                Response.Redirect("~/ManageProfile.aspx?sel=payment");
                return;
            }

            CurrentUserSession.Credits -= credits /*Config.Credits.CreditsForVideoStream*/;
            CurrentUserSession.Update(true);

            CreditsHistory creditsHistory = new CreditsHistory(CurrentUserSession.Username);
            creditsHistory.Amount = credits;//Config.Credits.CreditsForVideoStream;
            creditsHistory.Service = CreditsHistory.eService.ViewVideoStream;
            creditsHistory.Save();

            UnlockedSection.UnlockSection(CurrentUserSession.Username, User.Username, UnlockedSection.SectionType.VideoStream,
                                          null, DateTime.Now.AddDays(Config.Credits.VideoStreamUnlockPeriod));
            pnlVideoStream.Visible = true;
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string targetUsername = Request.Params["targetUsername"];
            //string targetAge = Request.Params["targetAge"];
            //string targetSex = Request.Params["targetSex"];
            //string targetLocation = Request.Params["targetLocation"];

            if (targetUsername == null || CurrentUserSession == null)
            {
                RedirectToLoginPage();
                return;
            }

            if (Classes.User.IsUserBlocked(targetUsername, CurrentUserSession.Username))
            {
                StatusPageMessage =
                    String.Format(Lang.Trans("You are currently blocked from sending messages to {0}"), targetUsername);

                Response.Clear();

                Response.Write("<script type=\"text/javascript\">");
                Response.Write(String.Format("window.opener.window.location.href = '{0}/ShowStatus.aspx';", Config.Urls.Home));
                Response.Write("window.close();");
                Response.Write("</script>");

                Response.End();
                return;
            }

            try
            {
                string url =
                    String.Format("~/AjaxChat/MessengerWindow.aspx?init=1&target={0}",ViewedUser.Username);

                bool isSectionUnlocked =
                    UnlockedSection.IsSectionUnlocked(CurrentUserSession.Username, ViewedUser.Username, UnlockedSection.SectionType.IM, null);

                var permissionCheckResult = CurrentUserSession.CanIM();

                if (permissionCheckResult == PermissionCheckResult.No)
                {
                    RedirectToLoginPage();
                    return;
                }

                if (permissionCheckResult == PermissionCheckResult.Yes || isSectionUnlocked)
                {
                    Response.Redirect(url);
                    return;
                }

                if (permissionCheckResult == PermissionCheckResult.YesButPlanUpgradeNeeded ||
                    permissionCheckResult == PermissionCheckResult.YesButMoreCreditsNeeded)
                {
                    Session["BillingPlanOption"] = CurrentUserSession.BillingPlanOptions.CanIM;
                    Response.Clear();

                    Response.Write("<script type=\"text/javascript\">");
                    Response.Write(String.Format("window.opener.window.location.href = '{0}/Profile.aspx?sel=payment';", Config.Urls.Home));
                    Response.Write("window.close();");
                    Response.Write("</script>");

                    Response.End();
                    return;
                }

                if (permissionCheckResult == PermissionCheckResult.YesWithCredits)
                {
                    int credits = CurrentUserSession.BillingPlanOptions.CanIM.Credits;

                    CurrentUserSession.Credits -= credits;
                    CurrentUserSession.Update(true);

                    CreditsHistory creditsHistory = new CreditsHistory(CurrentUserSession.Username);
                    creditsHistory.Amount = credits;
                    creditsHistory.Service = CreditsHistory.eService.UseIM;
                    creditsHistory.Save();

                    UnlockedSection.UnlockSection(CurrentUserSession.Username, ViewedUser.Username, UnlockedSection.SectionType.IM,
                                                  null, DateTime.Now.AddDays(Config.Credits.IMUnlockPeriod));

                    Response.Redirect(url);
                    return;
                }

                //if (IMLocked)
                //{
                //    int credits = CurrentUserSession.BillingPlanOptions.CanIM.Credits;

                //    if (CurrentUserSession.Credits - credits < 0)
                //    {
                //        //lblError.Text = Lang.Trans("You don't have enough credits to start new chat session");
                //        Response.Clear();

                //        Response.Write("<script type=\"text/javascript\">");
                //        Response.Write(String.Format("window.opener.window.location.href = '{0}/Profile.aspx?sel=payment';", Config.Urls.Home));
                //        Response.Write("window.close();");
                //        Response.Write("</script>");

                //        Response.End();
                //        return;
                //    }

                //    CurrentUserSession.Credits -= credits;
                //    CurrentUserSession.Update(true);

                //    CreditsHistory creditsHistory = new CreditsHistory(CurrentUserSession.Username);
                //    creditsHistory.Amount = credits;
                //    creditsHistory.Service = CreditsHistory.eService.UseIM;
                //    creditsHistory.Save();

                //    UnlockedSection.UnlockSection(CurrentUserSession.Username, ViewedUser.Username, UnlockedSection.SectionType.IM,
                //                                  null, DateTime.Now.AddDays(Config.Credits.IMUnlockPeriod));

                //    Response.Redirect(url);
                //}
                //else
                //{
                //    Response.Redirect(url);
                //}
            }
            catch (NotFoundException) {
                return; }
        }