Example #1
0
        partial void AddSupplier_Execute()
        {
            if (Suppliers.SelectedItem != null)
            {
                BidList blExist = new BidList();
                foreach (BidList blSearch in this.BidLists)
                {
                    if (blSearch.Supplier == this.Suppliers.SelectedItem)
                    {
                        blExist = blSearch;
                        blSearch.Delete();
                        this.DataWorkspace.ProcurementData.Details.DiscardChanges();
                        this.BidLists.Refresh();
                    }
                }

                if (blExist == null || blExist.Supplier == null)
                {
                    blExist.Delete();
                    BidList bl = BidLists.AddNew();
                    bl.Supplier  = Suppliers.SelectedItem;
                    bl.RFQ_PItem = this.RFQ_PItem;
                    this.Save();
                    this.BidLists.Refresh();
                }
            }
        }
Example #2
0
 void TrashCollector_Tick(object sender, EventArgs e)
 {
     while (TrashCan.Count > 0)
     {
         BidList.Remove(TrashCan.Dequeue());
     }
 }
Example #3
0
 public ActionResult Create(BidList m)
 {
     m.JobId = Int32.Parse(Session["JobId"].ToString());
     m.BidBy = Int32.Parse(Session["UserId"].ToString());
     BidRepo.Insert(m);
     return(RedirectToAction("Index", "JobList"));
 }
Example #4
0
        [Route("")] // Post Data
        public IHttpActionResult Post([FromBody] BidList bid)
        {
            repo.Insert(bid);
            string url = Url.Link("GetBitById", new { id = bid.BidId });

            bid.Links.Add(new Links()
            {
                HRef = "http://localhost:1569/api/jobbids", Method = "GET", Rel = "Get All Bids"
            });
            bid.Links.Add(new Links()
            {
                HRef = "http://localhost:1569/api/jobbids" + bid.BidId, Method = "GET", Rel = "Get a specific bid"
            });
            bid.Links.Add(new Links()
            {
                HRef = "http://localhost:1569/api/jobbids", Method = "POST", Rel = "Create a new bid"
            });
            bid.Links.Add(new Links()
            {
                HRef = "http://localhost:1569/api/jobbids" + bid.BidId, Method = "PUT", Rel = "Update specific bid"
            });
            bid.Links.Add(new Links()
            {
                HRef = "http://localhost:1569/api/jobbids" + bid.BidId, Method = "DELETE", Rel = "Delete specific bid"
            });
            return(Created(url, bid));
        }
Example #5
0
 [Route("{id}")] //Update Data
 public IHttpActionResult Put([FromBody] BidList bid, [FromUri] int id)
 {
     bid.BidId = id;
     repo.Update(bid);
     bid.Links.Add(new Links()
     {
         HRef = "http://localhost:1569/api/jobbids", Method = "GET", Rel = "Get All Bids"
     });
     bid.Links.Add(new Links()
     {
         HRef = "http://localhost:1569/api/jobbids" + bid.BidId, Method = "GET", Rel = "Get a specific bid"
     });
     bid.Links.Add(new Links()
     {
         HRef = "http://localhost:1569/api/jobbids", Method = "POST", Rel = "Create a new bid"
     });
     bid.Links.Add(new Links()
     {
         HRef = "http://localhost:1569/api/jobbids" + bid.BidId, Method = "PUT", Rel = "Update specific bid"
     });
     bid.Links.Add(new Links()
     {
         HRef = "http://localhost:1569/api/jobbids" + bid.BidId, Method = "DELETE", Rel = "Delete specific bid"
     });
     return(Ok(bid));
 }
Example #6
0
        // GET: Bids/Details/5
        public JsonResult Details(int?id)
        {
            BidList bidlist = new BidList();

            bidlist.Bid = db.Bids.Where(b => b.ItemID == id).ToList();

            if (bidlist.Bid.Count() > 0)
            {
                var list = bidlist.Bid.Select(b => new { b.BuyerName, b.Price }).OrderByDescending(i => i.Price).ToList();
                return(Json(list, JsonRequestBehavior.AllowGet));
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }
        public void TestMethod1()
        {
            BidList auction = new BidList();

            // create some bidders
            Bidder amy   = new Bidder(auction);
            Bidder julie = new Bidder(auction);
            Bidder pat   = new Bidder(auction);

            // submit some bids to the auction
            auction.SubmitBid(new Bid {
                Name = "Amy", Value = 150
            });
            auction.SubmitBid(new Bid {
                Name = "Julie", Value = 160
            });
            auction.SubmitBid(new Bid {
                Name = "Amy", Value = 165
            });
            auction.SubmitBid(new Bid {
                Name = "Julie", Value = 170
            });
            auction.SubmitBid(new Bid {
                Name = "Pat", Value = 175
            });

            // The bidding has gone too high for Amy.
            auction.RemoveBidder(amy);

            // few more bids
            auction.SubmitBid(new Bid {
                Name = "Julie", Value = 180
            });
            auction.SubmitBid(new Bid {
                Name = "Pat", Value = 185
            });

            // now too high for Julie
            auction.RemoveBidder(julie);

            // this doesn't make sense, but just to show that
            // there is now only one observer (Pat)
            auction.SubmitBid(new Bid {
                Name = "Pat", Value = 190
            });
        }
Example #8
0
 public ActionResult BuyProduct(Products prod)
 {
     if (Session["UserID"] != null)
     {
         if (prod.isAuction == 1)
         {
             //Si aun queda tiempo de la subasta
             var subasta    = db.Auction.SqlQuery("SELECT * FROM Auction WHERE ProductID =" + prod.ProductID).First();
             var currentBid = db.BidList.SqlQuery("SELECT * FROM BidList WHERE AuctionID = " + subasta.AuctionID).ToList().Last();
             int userBid    = Convert.ToInt32(Request.Form["auctionBID"]);
             if (userBid >= currentBid.Bid + 100)
             {
                 BidList newBid = new BidList();
                 newBid.BidID     = db.BidList.Count() + 1;
                 newBid.AuctionID = currentBid.AuctionID;
                 newBid.UserID    = Convert.ToInt32(Session["UserID"]);
                 newBid.Bid       = userBid;
                 db.BidList.Add(newBid);
                 db.Products.Find(prod.ProductID).Price = userBid;
                 db.SaveChanges();
                 return(RedirectToAction("Index", "Home"));
             }
         }
         else
         {
             var    AccMoney = Convert.ToInt32(Session["AccMoney"]);
             int    quantity;
             String Squantity = Request.Form["quantity"];
             if (Squantity != null)
             {
                 quantity = Convert.ToInt32(Squantity);
                 if (quantity <= prod.Existencies && quantity != 0 && prod.Existencies != 0)
                 {
                     if (AccMoney >= prod.Price * quantity)
                     {
                         //Take money from buyer
                         Session["AccMoney"] = AccMoney - prod.Price * quantity;
                         db.Users.Find(Session["UserID"]).AccMoney = Convert.ToInt32(Session["AccMoney"]);
                         //Give money to the seller
                         db.Users.Find(prod.UserID).AccMoney = db.Users.Find(prod.UserID).AccMoney + quantity * prod.Price;
                         //Movement of money
                         Movements mov = new Movements();
                         mov.UserID      = Convert.ToInt32(Session["UserID"]);
                         mov.MovementsID = db.Movements.Count() + 1;
                         mov.Ammount     = -1 * prod.Price * quantity; //(Es * -1 porque debe restar el valor de la cuenta original))
                         mov.Type        = "Compra";
                         db.Movements.Add(mov);
                         //Adding to list of bougth products
                         ProductsSold newSell = new ProductsSold();
                         newSell.SalesID    = db.ProductsSold.Count() + 1;
                         newSell.BuyerID    = Convert.ToInt32(Session["UserID"]);
                         newSell.SellerID   = prod.UserID;
                         newSell.ProductID  = prod.ProductID;
                         newSell.BuyDate    = DateTime.Today;
                         newSell.Price      = prod.Price;
                         newSell.Quantity   = quantity;
                         newSell.ShippingID = prod.ShippingID;
                         db.ProductsSold.Add(newSell);
                         //Actualizar las existencias de un producto
                         var productList = db.Products.ToList();
                         foreach (var product in productList)
                         {
                             if (product.ProductID == prod.ProductID)
                             {
                                 product.Existencies = product.Existencies - quantity;
                                 prod.Existencies    = product.Existencies;
                                 break;
                             }
                         }
                         db.SaveChanges();
                         return(RedirectToAction("Index", "Home"));
                     }
                 }
             }
             else
             {
                 quantity = 1;
             }
         }
     }
     return(View());
 }
Example #9
0
 public IActionResult UpdateBid(int id, [FromBody] BidList bidList)
 {
     // TODO: check required fields, if valid call service to update Bid and return list Bid
     return(Redirect("/bidList/list"));
 }
Example #10
0
 public IActionResult Validate([FromBody] BidList bidList)
 {
     // TODO: check data valid and save to db, after saving return bid list
     return(View("bidList/add"));
 }