protected void Page_Load(object sender, EventArgs e)
        {
            _DigitalGoodId = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]);
            _DigitalGood   = DigitalGoodDataSource.Load(_DigitalGoodId);
            if (_DigitalGood == null)
            {
                Response.Redirect("Default.aspx");
            }
            Caption.Text = string.Format(Caption.Text, _DigitalGood.Name);
            //GET ALL ORDER ITEMS ASSOCIATED WITH DIGITAL GOOD
            IList <OrderItemDigitalGood> oidgs = OrderItemDigitalGoodDataSource.LoadForDigitalGood(_DigitalGoodId);
            //BUILD DISTINCT LIST OF ORDERS
            List <Order> orders = new List <Order>();

            foreach (OrderItemDigitalGood oidg in oidgs)
            {
                Order order = oidg.OrderItem.Order;
                if (orders.IndexOf(order) < 0)
                {
                    orders.Add(order);
                }
            }
            //BIND TO GRID
            OrderGrid.DataSource = orders;
            OrderGrid.DataBind();
        }
        private static void HandleOrderItemDigitalGood(HttpContext context, HttpResponse Response, int orderItemDigitalGoodId)
        {
            OrderItemDigitalGood oidg = OrderItemDigitalGoodDataSource.Load(orderItemDigitalGoodId);

            // VERIFY DIGITAL GOOD IS VALID
            if (oidg != null)
            {
                // VERIFY REQUESTING USER PLACED THE ORDER
                OrderItem orderItem = oidg.OrderItem;
                if (orderItem != null)
                {
                    Order order = orderItem.Order;
                    if (order != null)
                    {
                        if (AbleContext.Current.UserId == order.User.Id)
                        {
                            // VERIFY THE DOWNLOAD IS VALID
                            if (oidg.DownloadStatus == DownloadStatus.Valid)
                            {
                                DigitalGood digitalGood = oidg.DigitalGood;
                                if (digitalGood != null)
                                {
                                    // RECORD THE DOWNLOAD
                                    Uri    referrer    = context.Request.UrlReferrer;
                                    string referrerUrl = (referrer != null) ? referrer.ToString() : string.Empty;
                                    oidg.RecordDownload(context.Request.UserHostAddress, context.Request.UserAgent, referrerUrl);
                                    DownloadHelper.SendFileDataToClient(context, digitalGood);
                                }
                                else
                                {
                                    Response.Write("The requested file could not be located.");
                                }
                            }
                            else
                            {
                                Response.Write("This download is expired or invalid.");
                            }
                        }
                        else
                        {
                            Response.Write("You are not authorized to download the requested file.");
                        }
                    }
                    else
                    {
                        Response.Write("The order could not be loaded.");
                    }
                }
                else
                {
                    Response.Write("The order item could not be loaded.");
                }
            }
            else
            {
                Response.Write("The requested item does not exist.");
            }
        }
        protected void Page_Init(object sender, System.EventArgs e)
        {
            _DigitalGoodId = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]);
            _DigitalGood   = DigitalGoodDataSource.Load(_DigitalGoodId);
            if (_DigitalGood == null)
            {
                Response.Redirect("Default.aspx");
            }
            Caption.Text            = string.Format(Caption.Text, _DigitalGood.Name);
            InstructionText.Text    = string.Format(InstructionText.Text, _DigitalGood.Name);
            ProductsGrid.DataSource = _DigitalGood.ProductDigitalGoods;
            ProductsGrid.DataBind();
            //GET ALL ORDER ITEMS ASSOCIATED WITH DIGITAL GOOD
            IList <OrderItemDigitalGood> oidgs = OrderItemDigitalGoodDataSource.LoadForDigitalGood(_DigitalGoodId);
            //BUILD DISTINCT LIST OF ORDERS
            List <CommerceBuilder.Orders.Order> orders = new List <CommerceBuilder.Orders.Order>();

            foreach (OrderItemDigitalGood oidg in oidgs)
            {
                CommerceBuilder.Orders.Order order = oidg.OrderItem.Order;
                if (orders.IndexOf(order) < 0)
                {
                    orders.Add(order);
                }
            }
            //BIND TO GRID
            OrderGrid.DataSource = orders;
            OrderGrid.DataBind();

            if (!String.IsNullOrEmpty(_DigitalGood.FileName))
            {
                ICriteria criteria = NHibernateHelper.CreateCriteria <DigitalGood>();
                criteria.Add(Restrictions.Eq("FileName", StringHelper.SafeSqlString(_DigitalGood.FileName)));
                IList <DigitalGood> dgc = DigitalGoodDataSource.LoadForCriteria(criteria);
                if (dgc != null && dgc.Count > 1)
                {
                    DeleteAllowedPanel.Visible   = false;
                    DeletePreventedPanel.Visible = true;
                    NoDeleteFileText.Text        = string.Format(NoDeleteFileText.Text, _DigitalGood.FileName);
                }
                else
                {
                    DeleteAllowedPanel.Visible   = true;
                    DeletePreventedPanel.Visible = false;
                    DeleteFile.Text = string.Format(DeleteFile.Text, _DigitalGood.FileName);
                }
            }
        }
 protected void Page_Init(object sender, EventArgs e)
 {
     _OrderItemDigitalGoodId = AlwaysConvert.ToInt(Request.QueryString["OrderItemDigitalGoodId"]);
     _OrderItemDigitalGood   = OrderItemDigitalGoodDataSource.Load(_OrderItemDigitalGoodId);
     if (_OrderItemDigitalGood == null)
     {
         Response.Redirect("MyAccount.aspx");
     }
     if ((_OrderItemDigitalGood.OrderItem.Order.UserId != AbleContext.Current.UserId) && (!AbleContext.Current.User.IsInRole(Role.OrderAdminRoles)))
     {
         Response.Redirect(AbleCommerce.Code.NavigationHelper.GetStoreUrl(this.Page, "Members/MyAccount.aspx"));
     }
     //UPDATE CAPTION
     Caption.Text       = String.Format(Caption.Text, _OrderItemDigitalGood.DigitalGood.Name);
     SerialKeyData.Text = _OrderItemDigitalGood.SerialKeyData;
 }
        protected void SaveKeyButton_Click(object sender, EventArgs e)
        {
            OrderItemDigitalGood oidg = OrderItemDigitalGoodDataSource.Load(AlwaysConvert.ToInt(this.OidgId.Value));

            if (oidg != null)
            {
                // WE NEED TO UPDATE THE CURRENT LOADED LIST TO AVOID DISPLAY ISSUES
                int i = _Order.Items.IndexOf(oidg.OrderItem.Id);
                int j = _Order.Items[i].DigitalGoods.IndexOf(oidg.Id);
                OrderItemDigitalGood tempOidg = _Order.Items[i].DigitalGoods[j];
                tempOidg.SetSerialKey(SerialKeyData.Text, true);
                tempOidg.Save();
                OidgId.Value = String.Empty;
                BindDigitalGoodsGrid();
                EditKeyPopup.Hide();
            }
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // get settings that impact menu tabs
            User user = AbleContext.Current.User;
            StoreSettingsManager settings = AbleContext.Current.Store.Settings;
            bool isRegistered             = !user.IsAnonymous;

            // construct links
            NameValueCollection menuLinks = new NameValueCollection();

            if (isRegistered)
            {
                menuLinks.Add("Orders", "MyAccount.aspx");
                if (SubscriptionDataSource.CountForUser(user.Id) > 0)
                {
                    menuLinks.Add("Subscriptions", "MySubscriptions.aspx");
                }

                if (OrderItemDigitalGoodDataSource.CountForUser(user.Id) > 0 || DigitalGoodDataSource.FindByUserGroupsCount(user.Id) > 0)
                {
                    menuLinks.Add("Digital Goods", "MyDigitalGoods.aspx");
                }
            }

            if (settings.WishlistsEnabled)
            {
                menuLinks.Add("Wishlist", "MyWishlist.aspx");
            }

            if (isRegistered)
            {
                menuLinks.Add("Profile", "MyCredentials.aspx");
                if (settings.EnablePaymentProfilesStorage && !AbleContext.Current.User.IsAnonymousOrGuest)
                {
                    menuLinks.Add("Payment Types", "PaymentTypes.aspx");
                }
                menuLinks.Add("Address Book", "MyAddressBook.aspx");

                if (settings.ProductReviewEnabled != CommerceBuilder.Users.UserAuthFilter.None)
                {
                    menuLinks.Add("Product Reviews", "MyProductReviews.aspx");
                }
            }

            int affiliateCount = UserDataSource.LoadUserAffiliateAccounts(user.Id).Count;

            if (affiliateCount > 0 || settings.AffiliateAllowSelfSignup)
            {
                menuLinks.Add("Affiliate Program", "MyAffiliateAccount.aspx");
            }

            // determine active page
            string activePage = Request.Url.Segments[Request.Url.Segments.Length - 1].ToLowerInvariant();

            // build menu
            StringBuilder menu = new StringBuilder();

            menu.AppendLine("<div class=\"tabstrip\">");
            menu.AppendLine("<ul>");
            foreach (string key in menuLinks.AllKeys)
            {
                if (IsActive(activePage, menuLinks[key].ToLowerInvariant()))
                {
                    menu.Append("<li class=\"active\">");
                }
                else
                {
                    menu.Append("<li>");
                }
                menu.AppendLine("<a href=\"" + Page.ResolveUrl("~/Members/" + menuLinks[key]) + "\">" + key + "</a></li>");
            }
            menu.AppendLine("</ul>");
            menu.AppendLine("</div>");
            MenuContent.Text = menu.ToString();
        }
        protected int GetOrderCount(object dataItem)
        {
            DigitalGood m = (DigitalGood)dataItem;

            return(OrderItemDigitalGoodDataSource.CountForDigitalGood(m.Id));
        }
Beispiel #8
0
 private IList <OrderItemDigitalGood> GetDigitalGoods()
 {
     return(OrderItemDigitalGoodDataSource.LoadForUser(AbleContext.Current.UserId));
 }