示例#1
0
 [HttpGet]                              //insert route as well?
 public ActionResult BidGetInfo(int id) //sets up bid creation
 {
     using (dbEntities db = new dbEntities())
     {
         double     CurrentLowestBid = db.Jobs.Where(o => o.Id == id).Single().StartPrice;
         List <Bid> temp             = db.Jobs.Where(o => o.Id == id).Single().Bids.ToList();
         foreach (var b in temp)
         {
             if (CurrentLowestBid > b.Price)
             {
                 CurrentLowestBid = b.Price;
             }
         }
         BiddingPageViewModel SetUp = new BiddingPageViewModel()
         {
             BidId         = -1, //temp value for now
             StartingPrice = db.Jobs.Where(o => o.Id == id).Single().StartPrice,
             LowestPrice   = CurrentLowestBid,
             UserId        = (int)Session["loginid"], //UNCOMMENT THIS UPON MERGE AND DELETE ABOVE LINE
             JobId         = id,
             Title         = db.Jobs.Where(o => o.Id == id).Single().Title,
             EmployerID    = db.Jobs.Where(o => o.Id == id).Single().EmployerId,
             JobDesc       = db.Jobs.Where(o => o.Id == id).Single().JobDec,
             CanBid        = db.Jobs.Where(o => o.Id == id).Single().CanBid,
         };
         TempData["BiddingPageViewModel"] = SetUp;
         return(View("~/Views/Bid/Bid.cshtml", SetUp));
     }
 }
示例#2
0
        public ActionResult CreateBid([Bind(Include = "BidId, StartingPrice, LowestPrice, UserId, JobId, Title, EmployeerID, JobDesc, CanBid")] BiddingPageViewModel model)
        {
            BiddingPageViewModel OldData = (BiddingPageViewModel)TempData["BiddingPageViewModel"]; //persisted data

            using (dbEntities db = new dbEntities())
            {
                if (ModelState.IsValid && OldData.CanBid == 1)
                {
                    int id2 = db.Bids.Count();
                    Bid bid = new Bid()
                    {
                        Id     = id2 + 1,
                        Price  = model.StartingPrice,
                        UserId = (int)Session["loginid"],     //UNCOMMENT THIS UPON MERGE AND DELETE ABOVE LINE
                        JobId  = OldData.JobId
                    };

                    db.Bids.Add(bid);
                    db.SaveChanges();
                    return(RedirectToAction("Display", "DisplayJob", new { id = OldData.JobId })); //parameter will send to ajay view for specific job needs to come up with it
                }

                return(View()); //redirect to partial view possibly for error handling
            }
        }