Ejemplo n.º 1
0
        protected void SubmitMultiBids(object sender, EventArgs e)
        {
            using (var ds = new ASEntities())
            {
                var account   = ds.Users.First(x => x.Username == Context.User.Identity.Name);
                var accountID = account.UserID;
                var godaddy   = ds.GoDaddyAccount.FirstOrDefault(x => x.UserID == accountID);
                var bidvalue  = fullApplyvalue.Value;
                if (godaddy != null)
                {
                    var bids =
                        ds.AuctionSearch.Where(
                            x =>
                            x.AccountID == godaddy.AccountID);

                    foreach (GridViewRow auc in LunchboxGridView4.Rows)
                    {
                        var myminbid   = (auc.FindControl("bidvalue") as TextBox).Text;
                        var auctionRef = auc.Cells[1].Text;

                        var bid =
                            bids.First(
                                x =>
                                x.AuctionRef == auctionRef);

                        var enddate    = new GoDaddyAuctions().GetEndDate(bid.AuctionRef);
                        var linkedRuid = Guid.NewGuid();
                        var auction    = new Auctions
                        {
                            AuctionID       = linkedRuid,
                            AuctionRef      = bid.AuctionRef,
                            DomainName      = bid.DomainName,
                            BidCount        = bid.BidCount,
                            Traffic         = bid.Traffic,
                            Valuation       = bid.Valuation,
                            Price           = bid.Price,
                            MinBid          = bid.MinBid,
                            MinOffer        = bid.MinOffer,
                            BuyItNow        = bid.BuyItNow,
                            EndDate         = enddate,
                            EstimateEndDate = bid.EstimateEndDate,
                            AccountID       = bid.AccountID,
                            Status          = bid.Status,
                            MyBid           = string.IsNullOrEmpty(myminbid) ? int.Parse(bidvalue) : TryParse_INT(myminbid, int.Parse(bidvalue))
                        };
                        var toRemove =
                            ds.Auctions.FirstOrDefault(
                                x => x.AccountID == godaddy.AccountID && x.AuctionRef == bid.AuctionRef);
                        if (toRemove != null)
                        {
                            ds.Auctions.Remove(toRemove);
                        }
                        ds.Auctions.AddOrUpdate(auction);
                        ds.SaveChanges();

                        var item = new AuctionHistory
                        {
                            HistoryID   = Guid.NewGuid(),
                            Text        = "Auction Added",
                            CreatedDate = DateTime.Now,
                            AuctionLink = auction.AuctionID
                        };
                        ds.AuctionHistory.Add(item);

                        var winalert = new Alerts
                        {
                            AuctionID   = auction.AuctionID,
                            Custom      = false,
                            Description = "WIN ALERT",
                            TriggerTime = auction.EndDate.AddMinutes(5)
                        };
                        ds.Alerts.Add(winalert);

                        var bidalert = new Alerts
                        {
                            AlertID     = Guid.NewGuid(),
                            AuctionID   = auction.AuctionID,
                            Custom      = false,
                            Description = "12 Hour Alert",
                            TriggerTime = auction.EndDate.AddHours(-12)
                        };
                        ds.Alerts.Add(bidalert);

                        var bidalert2 = new Alerts
                        {
                            AlertID     = Guid.NewGuid(),
                            AuctionID   = auction.AuctionID,
                            Custom      = false,
                            Description = "1 Hour Alert",
                            TriggerTime = auction.EndDate.AddHours(-1)
                        };
                        ds.Alerts.Add(bidalert2);
                        ds.SaveChanges();
                    }
                }

                ds.SaveChanges();
            }
            const string script = "window.location='" + "Default.aspx?redirect=mybids" + "';";

            ScriptManager.RegisterStartupScript(this, typeof(Page), "RedirectTo", script, true);
            //Response.Redirect("Default.aspx#mybids", true);
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Title        = @"Auction Sniper WEB";
            Welcome.Text = @"Hello, " + Context.User.Identity.Name + @"    ";
            if (IsPostBack)
            {
                SaveSearchSettings();
                SetSearchValues();
            }
            SetSearchValues();
            //FixHiddenValues();

            if (!IsPostBack)
            {
                LoadSavedSearchs();
                SetupAdv();
                if (Request.QueryString["redirect"] != null)
                {
                    Response.Redirect("Default.aspx#" + Request.QueryString["redirect"], true);
                }

                if (Request.QueryString["bookId"] != null && Request.QueryString["bidvalue"] != null)
                {
                    using (var ds = new ASEntities())
                    {
                        var biddref = Request.QueryString["bookId"];
                        var mybid   = Request.QueryString["bidvalue"];
                        if (GdAccount != null)
                        {
                            var bid =
                                ds.AuctionSearch.First(
                                    x =>
                                    x.AccountID == GdAccount.AccountID &&
                                    x.AuctionRef == biddref);

                            var enddate    = new GoDaddyAuctions().GetEndDate(biddref);
                            var linkedRuid = Guid.NewGuid();
                            var auction    = new Auctions
                            {
                                AuctionID       = linkedRuid,
                                AuctionRef      = bid.AuctionRef,
                                DomainName      = bid.DomainName,
                                BidCount        = bid.BidCount,
                                Traffic         = bid.Traffic,
                                Valuation       = bid.Valuation,
                                Price           = bid.Price,
                                MinBid          = bid.MinBid,
                                MinOffer        = bid.MinOffer,
                                BuyItNow        = bid.BuyItNow,
                                EndDate         = enddate,
                                EstimateEndDate = bid.EstimateEndDate,
                                AccountID       = bid.AccountID,
                                Status          = bid.Status,
                                MyBid           = int.Parse(mybid)
                            };
                            var toRemove = ds.Auctions.FirstOrDefault(x => x.AccountID == GdAccount.AccountID && x.AuctionRef == biddref);
                            if (toRemove != null)
                            {
                                ds.Auctions.Remove(toRemove);
                            }
                            ds.Auctions.AddOrUpdate(auction);
                            ds.SaveChanges();

                            var item = new AuctionHistory
                            {
                                HistoryID   = Guid.NewGuid(),
                                Text        = "Auction Added",
                                CreatedDate = DateTime.Now,
                                AuctionLink = auction.AuctionID
                            };
                            ds.AuctionHistory.Add(item);

                            var winalert = new Alerts
                            {
                                AuctionID   = auction.AuctionID,
                                Custom      = false,
                                Description = "WIN ALERT",
                                TriggerTime = auction.EndDate.AddMinutes(5)
                            };
                            ds.Alerts.Add(winalert);

                            var bidalert = new Alerts
                            {
                                AlertID     = Guid.NewGuid(),
                                AuctionID   = auction.AuctionID,
                                Custom      = false,
                                Description = "12 Hour Alert",
                                TriggerTime = auction.EndDate.AddHours(-12)
                            };
                            ds.Alerts.Add(bidalert);

                            var bidalert2 = new Alerts
                            {
                                AlertID     = Guid.NewGuid(),
                                AuctionID   = auction.AuctionID,
                                Custom      = false,
                                Description = "1 Hour Alert",
                                TriggerTime = auction.EndDate.AddHours(-1)
                            };
                            ds.Alerts.Add(bidalert2);
                            ds.SaveChanges();
                        }
                    }
                    Response.Redirect("Default.aspx#mybids");
                }
            }

            LoadAuctions();
        }