public void CreateNewBid(BidModel bid) { DbConnection.Open(); MySqlCommand command = DbConnection.CreateCommand(); command.CommandText = "INSERT INTO bid (owner,noticeid,pdfdoc) values(@owner,@noticeid,@pdfdoc)"; command.Parameters.AddWithValue("@owner", bid.Owner); command.Parameters.AddWithValue("@noticeid", bid.NoticeId); command.Parameters.AddWithValue("@pdfdoc", bid.PdfDoc); command.ExecuteNonQuery(); DbConnection.Close(); }
public ActionResult AddBid() { // create a new bid if (Request.HttpMethod.Equals("POST")) { BidModel bid = new BidModel(); bid.Owner = (String)Session["username"]; bid.NoticeId = int.Parse(Request.Form["noticeid"]); HttpPostedFileBase file = Request.Files["PDF"]; if (file != null && file.ContentLength > 0) // upload PDF document { System.IO.Stream fileStream = file.InputStream; byte[] data = new byte[file.ContentLength]; fileStream.Read(data, 0, data.Length); fileStream.Close(); bid.PdfDoc = data; } DBContext.GetInstance().CreateNewBid(bid); return RedirectToAction("BidDashboard", "Bidder"); } return RedirectToAction("BidDashboard", "Bidder"); // return to dashboard after creating it. }