public ActionResult ChooseLocation(int id) { int ordID = Convert.ToInt32(Session["OrderID"]); ProductOrder por = db.ProductOrders.Where(po => po.ProductOrderID == ordID).Include(po => po.Location.Client.User).FirstOrDefault(); por.LocationID = id; por.ProductOrderStatusID = 2; por.DateOfOrder = DateTime.Now; db.SaveChanges(); SendEmailController se = new SendEmailController(); se.OrderConfrimed(por); if (Convert.ToInt32(Session["UserRoleID"]) == 1) { return(RedirectToAction("MakePayment")); } else { TempData["SuccessMessage"] = "Order placed!"; return(RedirectToAction("Index", "Client")); } //Come the f**k on and merge already f*****g hell }
public ActionResult FinalizeOrder(string options) { db.Configuration.ProxyCreationEnabled = false; int SuppOrdID = Convert.ToInt32(TempData["SuppOrdID"]); SupplierOrder so = db.SupplierOrders .Where(sl => sl.SupplierOrderID == SuppOrdID) .Include(sl => sl.Supplier) .Include(sl => sl.SupplierOrderLines.Select(l => l.Product)) .FirstOrDefault(); so.SupplierStatusID = 6; so.OrderDate = DateTime.Today; db.SaveChanges(); if (options == "yes") { try { SendEmailController sendemail = new SendEmailController(); sendemail.NewSupplierOrderEmail(so); TempData["SuccessMessage"] = "Order request made - Email Sent"; return(RedirectToAction("Index")); } catch (Exception) { TempData["ErrorMessage"] = "Email error - Email not sent"; return(RedirectToAction("Index")); } } TempData["SuccessMessage"] = "Order request made"; return(RedirectToAction("Index")); }