//// GET: AdminBid/Bid/5 public ActionResult Bid(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblRoll tblRoll = db.tblRolls.Find(id); if (tblRoll == null) { return(HttpNotFound()); } ViewBag.rollIDBag = tblRoll.RollId; ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId); ViewBag.BuyerId = new SelectList(db.tblCustomers.OrderBy(t => t.CompanyName), "ID", "CompanyName", tblRoll.BuyerId); ViewBag.CustomerNumber = db.BuyerNoes.OrderBy(t => t.BuyerNumber).Where(g => g.CustomerID != null).Select(rr => new SelectListItem { Value = rr.CustomerID.ToString(), Text = rr.BuyerNumber + " (" + rr.tblCustomer.CompanyName + ")" }).ToList(); //ViewBag.CustomerNumber = new SelectList(db.BuyerNoes.OrderBy(t => t.BuyerNumber).Where(g => g.CustomerID != null), "CustomerID", "BuyerNumber", tblRoll.BuyerId); return(View(tblRoll)); }
public ActionResult DeleteConfirmed(int id) { tblRoll tblRoll = db.tblRolls.Find(id); db.tblRolls.Remove(tblRoll); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,RollId,Lot,SpeciesCode,TagNr,Age,DateMeasured,HornLength,TipToTip,OtherInfo,DateAvailable,Male,Female,Young,Quantity,Quantity_Lot,SellerId,BuyerId,BiddingPrice,BidDateTime,BidTotalPrice,NewBidPrice,NewBidder,Picture,OnAuction,Sold,DateLoaded,DateSold,PicturePath,PictureName,Increments,ReservePrice,LotQ,DateTimeBid,DateTimeClose,CustomerNumber,BidOpen")] tblRoll tblRoll) { if (ModelState.IsValid) { db.Entry(tblRoll).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblRoll)); }
// GET: Bid/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblRoll tblRoll = db.tblRolls.Find(id); if (tblRoll == null) { return(HttpNotFound()); } return(View(tblRoll)); }
public ActionResult Edit([Bind(Include = "ID,RollId,Lot,SpeciesCode,TagNr,Age,DateMeasured,HornLength,TipToTip,OtherInfo,DateAvailable,Male,Female,Young,Quantity,Quantity_Lot,SellerId,BuyerId,BiddingPrice,BidDateTime,BidTotalPrice,NewBidPrice,NewBidder,Picture,OnAuction,Sold,DateLoaded,DateSold,PicturePath,PictureName,Increments,ReservePrice,LotQ,CustomerNumber,DateTimeBid,DateTimeClose,BidOpen")] tblRoll tblRoll) { if (ModelState.IsValid) { Session["SelectedAuctionID"] = tblRoll.RollId.ToString(); // Set sesion var met wat geselekteer is db.Entry(tblRoll).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { AuctionID = tblRoll.RollId })); } ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId); ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId); ViewBag.SpeciesCode = new SelectList(db.ltSpecies, "ID", "Description", tblRoll.SpeciesCode); // ViewBag.SpeciesCode = new SelectList(db.Species, "ID", "NameAfr", tblRoll.SpeciesCode); ViewBag.BuyerId = new SelectList(db.tblCustomers, "ID", "CompanyName", tblRoll.BuyerId); ViewBag.SellerId = new SelectList(db.tblCustomers, "ID", "CompanyName", tblRoll.SellerId); Session["SelectedAuctionID"] = tblRoll.RollId.ToString(); // Set sesion var met wat geselekteer is return(View(tblRoll)); }
public ActionResult Bid([Bind(Include = "ID,RollId,Lot,SpeciesCode,TagNr,Age,DateMeasured,HornLength,TipToTip,OtherInfo,DateAvailable,Male,Female,Young,Quantity,Quantity_Lot,SellerId,BuyerId,BiddingPrice,BidDateTime,BidTotalPrice,NewBidPrice,NewBidder,Picture,OnAuction,Sold,DateLoaded,DateSold,PicturePath,PictureName,Increments,ReservePrice,LotQ,DateTimeBid,DateTimeClose,CustomerNumber")] tblRoll tblRoll) { if (ModelState.IsValid) { BidController bd = new BidController(); Bid bid = new Bid(); bid.ID = tblRoll.ID; bid.BuyerId = Int32.Parse(tblRoll.CustomerNumber); bid.NewBidPrice = tblRoll.NewBidPrice; bid.RollId = tblRoll.RollId; // Kry die user inligting tblCustomer tblCustomersLog = db.tblCustomers.FirstOrDefault(i => i.CustomerID == User.Identity.Name); if (tblCustomersLog != null) { bid.UserID = tblCustomersLog.ID; // Kry ID van persoon wat ingelog het. } Bid dm = bd.BidLogic(bid); // Process bid! if (bid.bidToLow) { TempData["msg"] = "<script>alert('Bidding price must be higher than current bid + increment');</script>"; return(RedirectToAction("Bid", tblRoll.ID)); } if (bid.bidClosed) { TempData["msg"] = "<script>alert('Bid has closed');</script>"; // Moet dit toets return(RedirectToAction("Bid", tblRoll.ID)); } return(RedirectToAction("Index", new { AuctionID = tblRoll.RollId })); } ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId); ViewBag.BuyerId = new SelectList(db.tblCustomers, "ID", "CompanyName", tblRoll.BuyerId); // ViewBag.CustomerNumber = new SelectList(db.BuyerNoes, "CustomerID", "BuyerNumber", tblRoll.BuyerId); ViewBag.CustomerNumber = db.BuyerNoes.OrderBy(t => t.BuyerNumber).Where(g => g.CustomerID != null).Select(rr => new SelectListItem { Value = rr.CustomerID.ToString(), Text = rr.BuyerNumber + " (" + rr.tblCustomer.CompanyName + ")" }).ToList(); return(View(tblRoll)); }
// GET: RollAdmin/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblRoll tblRoll = db.tblRolls.Find(id); if (tblRoll == null) { return(HttpNotFound()); } ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId); ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId); ViewBag.SpeciesCode = new SelectList(db.ltSpecies, "ID", "Description", tblRoll.SpeciesCode); // ViewBag.SpeciesCode = new SelectList(db.Species, "ID", "NameAfr", tblRoll.SpeciesCode); ViewBag.BuyerId = new SelectList(db.tblCustomers, "ID", "CompanyName", tblRoll.BuyerId); ViewBag.SellerId = new SelectList(db.tblCustomers, "ID", "CompanyName", tblRoll.SellerId); return(View(tblRoll)); }
public ActionResult Index(AdminBidModel bid) { int lot = bid.LotID; int Buyer = bid.BuyerID; // tblRoll tblRollAfter = db.tblRolls.Find(bid.LotID); if (bid.NewBidPrice >= (tblRollAfter.BiddingPrice + tblRollAfter.Increments)) { tblCustomer tblCustomersLog = db.tblCustomers.FirstOrDefault(i => i.CustomerID == User.Identity.Name); if (DateTime.Now <= tblRollAfter.DateTimeClose) { //tblRoll.DateTimeBid = DateTime.Now; if (DateTime.Now.AddMinutes(15) >= tblRollAfter.DateTimeClose) { //tblRoll.DateTimeClose = DateTime.Now.AddMinutes(15); // tel 15 minute by sluitings tyd. db.UpdateBidTimeClose(bid.LotID, DateTime.Now.AddMinutes(15)); } // db.UpdateBidder(bid.LotID, bid.BuyerID, bid.NewBidPrice, (bid.NewBidPrice * tblRollAfter.Quantity), DateTime.Now, ); db.AddBidHistory(tblRollAfter.ID, tblRollAfter.RollId, tblRollAfter.Lot, tblRollAfter.SellerId, bid.BuyerID, bid.NewBidPrice, (bid.NewBidPrice * tblRollAfter.Quantity), DateTime.Now, tblCustomersLog.ID); } else { TempData["msg"] = "<script>alert('Bid has closed');</script>"; // Moet dit toets } } else { TempData["msg"] = "<script>alert('Bidding price must be higher than current bid + increment');</script>"; } // ViewBag.LotID = new SelectList(db.tblRolls, "Id", "Lot"); ViewBag.BuyerID = new SelectList(db.tblCustomers, "Id", "CustomerNumber").Where(t => t.Text != null && t.Text != ""); return(View()); }
// GET: RollAdmin/Create public ActionResult Create() { int?AuctionID; if (Session["SelectedAuctionID"] == null) // IF sesion var not created yet, create { BidController bd = new BidController(); DefaultSetupModel dm = bd.LoadDefs(0); // Get the default values AuctionID = dm.DefaultAuction; Session["SelectedAuctionID"] = AuctionID.ToString(); // Set sesion var met wat geselekteer is } else { AuctionID = Int32.Parse(Session["SelectedAuctionID"].ToString()); } ViewBag.auctionID = AuctionID; ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", AuctionID); // ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description"); ViewBag.SpeciesCode = new SelectList(db.ltSpecies, "ID", "Description"); ViewBag.BuyerId = new SelectList(db.tblCustomers, "ID", "CompanyName"); ViewBag.SellerId = new SelectList(db.tblCustomers, "ID", "CompanyName"); tblRoll rol = new tblRoll(); ltRollDescription ltRollDescription = db.ltRollDescriptions.Find(AuctionID); if (ltRollDescription != null) { rol.Quantity_Lot = "Animal"; rol.OnAuction = true; rol.DateTimeClose = ltRollDescription.EndDate; rol.DateLoaded = DateTime.Now; rol.BidOpen = true; } return(View(rol)); }
// GET: Bid/Edit/5 public ActionResult Bid(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblRoll tblRoll = db.tblRolls.Find(id); // store outgoing bidders details currentBuyer.NewBuyerID = tblRoll.BuyerId; // get the new buyer buyer's ID if (tblRoll == null) { return(HttpNotFound()); } ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId); ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId); ViewBag.SpeciesCode = new SelectList(db.ltSpecies, "ID", "Description", tblRoll.SpeciesCode); ViewBag.BuyerId = new SelectList(db.tblCustomers, "ID", "CustomerID", tblRoll.BuyerId); ViewBag.SellerId = new SelectList(db.tblCustomers, "ID", "CustomerID", tblRoll.SellerId); if (tblRoll.BiddingPrice == null) { tblRoll.BiddingPrice = 0; } if (tblRoll.Increments == null) { tblRoll.Increments = 0; } if (tblRoll.Quantity == null) { tblRoll.Quantity = 1; } // Get defauls string sessionID = "0"; int AuctionID = 0; if (Session["auctionID"] != null) // Should never be null { sessionID = Session["auctionID"].ToString(); AuctionID = Int32.Parse(sessionID); } DefaultSetupModel dm = LoadDefs(AuctionID); // Get the default values int?rollID = dm.ID; ViewBag.BackgroundColor = dm.BackgroundColor; ViewBag.TexColor = dm.FontColor; ViewBag.LogoBackgroundColor = dm.LogoBackgroundColor; ViewBag.ImagePath = dm.RollImagePath; ViewBag.LogoPath = dm.LogoPath; ViewBag.LogoName = dm.LogoName; ViewBag.RefreshTime = dm.RefreshTime.ToString(); ViewBag.ImagePath = dm.RollImagePath; ViewBag.emptyMessage = dm.message; ViewBag.RollImageBackColor = dm.RollImagesBackColor; string initApp; if (Session["InitApp"] == null) { Session["InitApp"] = "Web"; // creat InitApp as web init if nothing received } initApp = Session["InitApp"].ToString(); if (initApp == "App") { return(View("BidApp", tblRoll)); } else { return(View(tblRoll)); } }
// Hier public Bid BidLogic(Bid bid) { currentBuyer.NewBuyerHaveCellNumber = false; currentBuyer.OutBuyerHaveCellNumber = false; currentBuyer.NewBuyerID = bid.BuyerId; // Die nuwe id wat oorkom. using (AuctionDBEntities db = new AuctionDBEntities()) // make sure to get the latest info from DB and not the immage of DB. { tblRoll tblRollAfter = db.tblRolls.Find(bid.ID); // find the latest info on db. if (tblRollAfter.Increments == null) { tblRollAfter.Increments = 0; } if (tblRollAfter.BiddingPrice == null) { tblRollAfter.BiddingPrice = 0; } if (bid.NewBidPrice >= (tblRollAfter.BiddingPrice + tblRollAfter.Increments)) { double ExtendBitTime; bool AuctionSMS = false; ltRollDescription ltRollDescriptions = db.ltRollDescriptions.Find(bid.RollId); if (ltRollDescriptions != null) { ExtendBitTime = System.Convert.ToDouble(ltRollDescriptions.AuctionDelayTime); AuctionSMS = ltRollDescriptions.SmsNotification; } else { ExtendBitTime = 5; AuctionSMS = false; } // bid.BidTotalPrice = bid.NewBidPrice * tblRollAfter.Quantity; if (DateTime.Now <= tblRollAfter.DateTimeClose) { tblRollAfter.DateTimeBid = DateTime.Now; if (DateTime.Now.AddMinutes(ExtendBitTime) >= tblRollAfter.DateTimeClose) { tblRollAfter.DateTimeClose = DateTime.Now.AddMinutes(ExtendBitTime); // add time before close. db.UpdateBidTimeClose(bid.ID, tblRollAfter.DateTimeClose); } // Kan later weer terugsit. //if (currentBuyer.NewBuyerID != tblRollAfter.BuyerId) // Not same outgoing and new bidder. //{ // Get outgoing bidder info tblCustomer tblCustomersOut = db.tblCustomers.Find(tblRollAfter.BuyerId); currentBuyer.OutBuyerCell = tblCustomersOut.Phone; if (currentBuyer.OutBuyerCell != null && currentBuyer.OutBuyerCell != "") { currentBuyer.OutBuyerHaveCellNumber = true; } // Get incomming bidder info tblCustomer tblCustomersIn = db.tblCustomers.Find(currentBuyer.NewBuyerID); currentBuyer.NewBuyerCell = tblCustomersIn.Phone; if (currentBuyer.NewBuyerCell != null && currentBuyer.NewBuyerCell != "") { currentBuyer.NewBuyerHaveCellNumber = true; } // } // Huidige koper // Laaste voor update. tblRoll tblRollLast = db.tblRolls.Find(bid.ID); // find the latest info on db. if (tblRollLast.Increments == null) { tblRollLast.Increments = 0; } if (tblRollLast.BiddingPrice == null) { tblRollLast.BiddingPrice = 0; } if (bid.NewBidPrice >= (tblRollLast.BiddingPrice + tblRollLast.Increments)) { if (tblRollLast.Quantity_Lot == "Lot") { bid.BidTotalPrice = bid.NewBidPrice; } else { bid.BidTotalPrice = bid.NewBidPrice * tblRollAfter.Quantity; } // Kry die Auction Buyer Nommer string AuctionBuyerNumber; BuyerNo buyeNo = db.BuyerNoes.FirstOrDefault(t => t.CustomerID == bid.BuyerId && t.RollID == bid.RollId); if (buyeNo == null) { AuctionBuyerNumber = "INT " + bid.BuyerId.ToString(); } else { AuctionBuyerNumber = "B " + buyeNo.BuyerNumber; } db.UpdateBidder(bid.ID, bid.BuyerId, bid.NewBidPrice, bid.BidTotalPrice, tblRollAfter.DateTimeBid, AuctionBuyerNumber); db.AddBidHistory(bid.ID, bid.RollId, tblRollAfter.Lot, tblRollAfter.SellerId, bid.BuyerId, bid.NewBidPrice, bid.BidTotalPrice, tblRollAfter.DateTimeBid, bid.UserID); // Laai defaults DefaultSetupModel dm = LoadDefs(0); // Get the default values vir stuur van sms // Sal net sms stuur as koper cell het, spesifieke auction verys dit en default is aan. // Sms outgoing bidder if (currentBuyer.OutBuyerHaveCellNumber && AuctionSMS && dm.SMSAllFunctionality == true && dm.SMSOutBidder == true) { string x = string.Format("{0:0,000}", bid.NewBidPrice); smsMGT smg = new smsMGT(); string messagestring = $"Silent auction: Your bid for Lot {tblRollAfter.Lot} has been exceeded. Current bid is : R {x}"; var res = smg.SendSingleSMS("1", currentBuyer.OutBuyerCell, messagestring); if (res != "success") { string EmailSubject = "SMS NOT sent successfully"; string EMailBody = $"SMS NOT sent successfully to out bidder {tblCustomersOut.CompanyName}" + ". Error = " + res; sendEmail sm = new sendEmail(); string emalres = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null); } } // Sms new bidder. if (currentBuyer.NewBuyerHaveCellNumber && AuctionSMS && dm.SMSAllFunctionality == true && dm.SMSNewBidder == true) { string y = string.Format("{0:0,000}", bid.NewBidPrice); smsMGT smg = new smsMGT(); string messagestring = $"Silent auction: Your bid for Lot {tblRollAfter.Lot} has been accepted. Your bid is : R {y}"; var res = smg.SendSingleSMS("1", currentBuyer.NewBuyerCell, messagestring); if (res != "success") { string EmailSubject = "SMS NOT sent successfully"; string EMailBody = $"SMS NOT sent successfully to new bidder {tblCustomersIn.CompanyName}" + " " + res; sendEmail sm = new sendEmail(); string emalres = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null); } } if (bid.NewBidPrice >= (tblRollAfter.BiddingPrice + (tblRollAfter.Increments * 10))) { // email warning to NWWT sendEmail sm = new sendEmail(); string y = string.Format("{0:0,000}", bid.NewBidPrice); string z = string.Format("{0:0,000}", tblRollAfter.BiddingPrice); string EmailSubject = "An extraordinary high bid received"; string EMailBody = $"An extraordinary high bid was made on Lot {tblRollAfter.Lot} by {tblCustomersIn.CompanyName}. The new bid is : R {y} and the previous bid was R {z}"; string res = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null); } } else { bid.bidToLow = true; } } else { bid.bidClosed = true; } } else { bid.bidToLow = true; } } return(bid); }
public ActionResult Bid([Bind(Include = "ID,RollId,Lot,SpeciesCode,TagNr,Age,DateMeasured,HornLength,TipToTip,OtherInfo,DateAvailable,Male,Female,Young,Quantity,Quantity_Lot,SellerId,BuyerId,BiddingPrice,BidDateTime,BidTotalPrice,NewBidPrice,NewBidder,Picture,OnAuction,Sold,DateLoaded,DateSold,PicturePath,PictureName,Increments,ReservePrice,LotQ,DateTimeClose,CustomerNumber")] tblRoll tblRoll) { if (ModelState.IsValid) { // nuut BidController bd = new BidController(); Bid bid = new Bid(); bid.ID = tblRoll.ID; bid.NewBidPrice = tblRoll.NewBidPrice; bid.RollId = tblRoll.RollId; // Kry die user inligting // var user = UserManager.FindByNameAsync("PIET"); tblCustomer tblCustomersLog = db.tblCustomers.FirstOrDefault(i => i.CustomerID == User.Identity.Name); if (tblCustomersLog.PIN != tblRoll.CustomerNumber) { TempData["msg"] = "<script>alert('Incorrect PIN');</script>"; return(RedirectToAction("Bid", tblRoll.ID)); } if (tblCustomersLog != null) { bid.BuyerId = tblCustomersLog.ID; // Kry ID van persoon wat ingelog het. bid.UserID = tblCustomersLog.ID; // Buyer is ook User. } Bid dm = bd.BidLogic(bid); // Process bid! if (bid.bidToLow) { TempData["msg"] = "<script>alert('Bidding price must be higher than current bid + increment');</script>"; return(RedirectToAction("Bid", tblRoll.ID)); } if (bid.bidClosed) { TempData["msg"] = "<script>alert('Bid has closed');</script>"; // Moet dit toets return(RedirectToAction("Bid", tblRoll.ID)); } return(RedirectToAction("Index", new { AuctionID = tblRoll.RollId })); // end nuut } else { string initApp; if (Session["InitApp"] == null) { Session["InitApp"] = "Web"; // creat InitApp as web init if nothing received } initApp = Session["InitApp"].ToString(); if (initApp == "App") { return(View("BidApp", tblRoll)); } else { return(View(tblRoll)); } } }