Example #1
0
        private static CreditsHistory[] Fetch(int? id, string username, DateTime? date, eSortColumn sortColumn)
        {
            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader = (SqlDataReader) SqlHelper.GetDB().ExecuteReader( "FetchCreditsHistory",
                                                               id, username, date, sortColumn);

                List<CreditsHistory> lCreditsHistory = new List<CreditsHistory>();

                while (reader.Read())
                {
                    CreditsHistory creditsHistory = new CreditsHistory();

                    creditsHistory.id = (int)reader["ID"];
                    creditsHistory.username = (string)reader["Username"];
                    creditsHistory.date = (DateTime)reader["Date"];
                    creditsHistory.service = (eService)reader["Service"];
                    creditsHistory.amount = (int)reader["Amount"];

                    lCreditsHistory.Add(creditsHistory);
                }

                return lCreditsHistory.ToArray();
            }
        }
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)
            {
                Global.GetSessionState()["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;
            }

            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)
                {
                    Global.GetSessionState()["BillingPlanOption"] = CurrentUserSession.BillingPlanOptions.CanIM;
                    Response.Clear();

                    Response.Write("<script type=\"text/javascript\">");
                    Response.Write(String.Format("window.opener.window.location.href = '{0}/ManageProfile.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}/ManageProfile.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; }
        }
Example #4
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)
            {
                Global.GetSessionState()["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;
        }