public ActionResult DeleteConfirmed(long id) { FoodOrderDetail foodOrderDetail = db.FoodOrderDetails.Find(id); db.FoodOrderDetails.Remove(foodOrderDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "FdOdrDtID,FdOdrID,FdID,Qty")] FoodOrderDetail foodOrderDetail) { if (ModelState.IsValid) { db.Entry(foodOrderDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FdID = new SelectList(db.Foods, "FdID", "FdNm", foodOrderDetail.FdID); ViewBag.FdOdrID = new SelectList(db.FoodOrders, "FdOdrID", "Ttl", foodOrderDetail.FdOdrID); return(View(foodOrderDetail)); }
// GET: FoodOrderDetails/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FoodOrderDetail foodOrderDetail = db.FoodOrderDetails.Find(id); if (foodOrderDetail == null) { return(HttpNotFound()); } return(View(foodOrderDetail)); }
// GET: FoodOrderDetails/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FoodOrderDetail foodOrderDetail = db.FoodOrderDetails.Find(id); if (foodOrderDetail == null) { return(HttpNotFound()); } ViewBag.FdID = new SelectList(db.Foods, "FdID", "FdNm", foodOrderDetail.FdID); ViewBag.FdOdrID = new SelectList(db.FoodOrders, "FdOdrID", "Ttl", foodOrderDetail.FdOdrID); return(View(foodOrderDetail)); }
protected void btnPay_Click(object sender, EventArgs e) { // Customer Id string userId = ""; // Reservation Detail string type = ""; // Food Order string food_id = ""; string food_name = ""; string qty = ""; // Payment decimal totalPrice = 0; if (!string.IsNullOrEmpty(Session["Id"] as string)) { userId = Session["id"].ToString(); if (Page.IsValid) { int randomId; Random random = new Random(); bool repeatId = false; string cust_id; // Booking string bookingId = ""; int person = 0; string seatArea = ""; DateTime dt; // Booking person = int.Parse(Session["person"].ToString()); seatArea = Session["seatArea"].ToString(); dt = DateTime.Parse(Session["datetime"].ToString()); // Generate Booking Id do { randomId = random.Next(10000, 999999); bookingId = "RES" + randomId; var p = OneDB.ReservationBKs.SingleOrDefault(b => b.resID == bookingId); if (p == null) { repeatId = true; } } while (repeatId == false); //For random code generate var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var stringChars = new char[8]; for (int i = 0; i < stringChars.Length; i++) { stringChars[i] = chars[random.Next(chars.Length)]; } var finalString = new String(stringChars); cust_id = userId; ReservationBK book = new ReservationBK { resID = bookingId, resHeadCount = person, resArea = seatArea, resDate = dt, customer_ID = cust_id }; OneDB.ReservationBKs.InsertOnSubmit(book); OneDB.SubmitChanges(); // Reservation Detail string rd_id; type = Session["reserveType"].ToString(); string res_id; res_id = bookingId; // Generate Reservation Detail Id do { randomId = random.Next(10000, 999999); rd_id = "RD" + randomId; var p = OneDB.Reservation_Details.SingleOrDefault(b => b.resDetail_iD == rd_id); if (p == null) { repeatId = true; } } while (repeatId == false); //For random code generate var RDchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var RDstringChars = new char[8]; for (int i = 0; i < RDstringChars.Length; i++) { RDstringChars[i] = chars[random.Next(RDchars.Length)]; } var RDfinalString = new String(RDstringChars); // Insert in Reservation Detail Table Reservation_Detail resDetail = new Reservation_Detail { resDetail_iD = rd_id, resDetail_type = type, reservation_ID = res_id }; OneDB.Reservation_Details.InsertOnSubmit(resDetail); OneDB.SubmitChanges(); // Food Order food_name = Session["foodname"].ToString(); qty = Session["foodquantity"].ToString(); // Generate Reservation Id do { randomId = random.Next(10000, 999999); food_id = "FO" + randomId; var p = OneDB.Food_Orders.SingleOrDefault(b => b.foodID == food_id); if (p == null) { repeatId = true; } } while (repeatId == false); //For random code generate var FOchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var FOstringChars = new char[8]; for (int i = 0; i < FOstringChars.Length; i++) { FOstringChars[i] = chars[random.Next(FOchars.Length)]; } var FOfinalString = new String(FOstringChars); // Insert in Food Order Food_Order order = new Food_Order { foodID = food_id, }; OneDB.Food_Orders.InsertOnSubmit(order); OneDB.SubmitChanges(); // Food Order Detail string orderid = ""; food_name = Session["foodname"].ToString(); qty = Session["foodquantity"].ToString(); var id = food_id; // Generate Reservation Id do { randomId = random.Next(10000, 999999); orderid = "FD" + randomId; var p = OneDB.FoodOrderDetails.SingleOrDefault(b => b.OrderId == orderid); if (p == null) { repeatId = true; } } while (repeatId == false); //For random code generate var FDchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var FDstringChars = new char[8]; for (int i = 0; i < FDstringChars.Length; i++) { FDstringChars[i] = chars[random.Next(FDchars.Length)]; } var FDfinalString = new String(FDstringChars); // Insert in Food Order Detail FoodOrderDetail od = new FoodOrderDetail { OrderId = food_id, Id = orderid, foodName = food_name, quantity = qty }; OneDB.FoodOrderDetails.InsertOnSubmit(od); OneDB.SubmitChanges(); // Address string address_id; string firstName = txtFirst.Text; string lastName = txtLast.Text; string address = txtAddress.Text; string postcode = txtPostcode.Text; string state = txtState.Text; cust_id = userId; // Generate Reservation Id do { randomId = random.Next(10000, 999999); address_id = "ADD" + randomId; var p = OneDB.Addresses.SingleOrDefault(b => b.Id == address_id); if (p == null) { repeatId = true; } } while (repeatId == false); //For random code generate var ADchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var ADstringChars = new char[8]; for (int i = 0; i < ADstringChars.Length; i++) { ADstringChars[i] = chars[random.Next(ADchars.Length)]; } var ADfinalString = new String(ADstringChars); // Insert in Address Address a = new Address() { Id = address_id, FirstName = firstName, LastName = lastName, AddressLine = address, Postcode = postcode, State = state, Customer_ID = cust_id }; OneDB.Addresses.InsertOnSubmit(a); OneDB.SubmitChanges(); // Payment string pay_id; totalPrice = decimal.Parse(Session["total"].ToString()); DateTime payDate = DateTime.Now; cust_id = userId; string payFoodid = food_id; // Generate Reservation Id do { randomId = random.Next(10000, 999999); pay_id = "P" + randomId; var p = OneDB.Checkouts.SingleOrDefault(b => b.paymentID == pay_id); if (p == null) { repeatId = true; } } while (repeatId == false); //For random code generate var Pchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var PstringChars = new char[8]; for (int i = 0; i < PstringChars.Length; i++) { PstringChars[i] = chars[random.Next(Pchars.Length)]; } var PfinalString = new String(PstringChars); // Insert in Checkout Checkout c = new Checkout() { paymentID = pay_id, totalPrice = totalPrice, paymentDate = payDate, Customer_ID = cust_id, foodID = food_id }; OneDB.Checkouts.InsertOnSubmit(c); OneDB.SubmitChanges(); // Check In string chk_code = ""; // Generate Reservation Id randomId = random.Next(10000, 999999); chk_code = randomId.ToString(); //For random code generate var CHKchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var CHKstringChars = new char[6]; for (int i = 0; i < CHKstringChars.Length; i++) { CHKstringChars[i] = chars[random.Next(CHKchars.Length)]; } var CHKfinalString = new String(CHKstringChars); string booking = "Booking"; string status = "Pending"; // Insert in Check in Check_In chk = new Check_In { check_code = CHKfinalString, check_type = booking, check_status = status }; OneDB.Check_Ins.InsertOnSubmit(chk); OneDB.SubmitChanges(); var email = Session["email"]; // Send Email try { MailMessage mailMessage = new MailMessage(); mailMessage.To.Add(email.ToString()); mailMessage.From = new MailAddress("*****@*****.**"); mailMessage.Subject = "Verification Mail"; mailMessage.Body = "<h3>hi</h3> " + "<h2>your booking verification code are</h2> <p>" + "<h1>" + CHKfinalString + "</h1>"; mailMessage.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = "smtp.gmail.com"; smtpClient.Port = 587; smtpClient.Credentials = new System.Net.NetworkCredential ("*****@*****.**", "cornhub666lol"); smtpClient.EnableSsl = true; smtpClient.Send(mailMessage); } catch (Exception ex) { Response.Write("Unable to send the e-mail <br/>" + ex.Message); } displayStatus.Text = "Payment Successful!"; Server.Transfer("~/Reservation/PaymentSuccessful.aspx"); } } }
public ActionResult Addfood(Food createVM) { var userid = Convert.ToInt32(Session["Usrid"]); FoodOrderDetail fdodrdtls = new FoodOrderDetail(); Food fd = db.Foods.Where(x => x.FdID == createVM.FdID).FirstOrDefault(); FoodOrder fdodrobj = db.FoodOrders.Where(f => f.UserID == userid && f.isPaid == false).FirstOrDefault(); if (fdodrobj != null) { fdodrobj.Ttl = fdodrobj.Ttl + Convert.ToInt64(fd.FdRt) * Convert.ToInt64(createVM.FdRt);//qty db.Entry(fdodrobj).State = EntityState.Modified; db.SaveChanges(); fdodrdtls.FdID = fd.FdID; fdodrdtls.Qty = Convert.ToInt64(createVM.FdRt); fdodrdtls.FdOdrID = fdodrobj.FdOdrID; db.FoodOrderDetails.Add(fdodrdtls); db.SaveChanges(); } else { fdodrobj = new FoodOrder(); fdodrobj.Date = DateTime.Now; fdodrobj.isPaid = false; fdodrobj.UserID = userid; fdodrobj.RstID = createVM.RstID; fdodrobj.Ttl = Convert.ToInt64(fd.FdRt) * Convert.ToInt64(createVM.FdRt); db.FoodOrders.Add(fdodrobj); db.SaveChanges(); fdodrdtls.FdID = fd.FdID; fdodrdtls.Qty = Convert.ToInt64(createVM.FdRt); fdodrdtls.FdOdrID = fdodrobj.FdOdrID; db.FoodOrderDetails.Add(fdodrdtls); db.SaveChanges(); } var food = db.FoodOrderDetails.Where(f => f.FdOdrID == fdodrobj.FdOdrID); //FoodOrderDetail fd2 = db.FoodOrderDetails.Where(f => f.FdOdrID == fdodrobj.FdOdrID); //if (fd.FdNm != null && fdodrobj.Date == null ) //{ // fdodr.Date = DateTime.Now; // fdodr.isPaid = false; // fdodr.UserID = userid; // fdodr.Ttl = 0; // db.FoodOrders.Add(fdodr); // db.SaveChanges(); // fdodrdtls.FdID = fd.FdID; // fdodrdtls.Qty = 1; // fdodrdtls.FdOdrID = fdodrobj.FdOdrID; // db.FoodOrderDetails.Add(fdodrdtls); // db.SaveChanges(); // return View(); //} //else //{ // fdodrdtls.Qty = fdodrdtls.Qty + 1; // db.Entry(fdodrdtls).State = EntityState.Modified; // db.SaveChanges(); // fdodr.Ttl = 100; // db.Entry(fdodr).State = EntityState.Modified; // db.SaveChanges(); // return View(); //} return(RedirectToAction("Viewfood", "Foods", new { id = createVM.RstID })); }