public ActionResult CreateIndividual([Bind(Include = "orderId,orderDate,customerId,orderPrice,quantity,shoesName,comments")] ShoesOrder shoesOrder) { if (ModelState.IsValid) { db.ShoesOrders.Add(shoesOrder); db.SaveChanges(); return(RedirectToAction("IndexUserOrders")); } ShoesOrder order = new ShoesOrder(); string currentUserEmail = HttpContext.GetOwinContext() .GetUserManager <ApplicationUserManager>() .FindById(User.Identity.GetUserId()).Email; Boolean flag = false; int currentDBuserID = -1; foreach (var item in db.Customers) { if (item.customerEmail == currentUserEmail) { flag = true; currentDBuserID = item.customerId; } } order.customerId = currentDBuserID; return(View(order)); }
public ActionResult CreateIndividual() { string currentUserEmail = HttpContext.GetOwinContext() .GetUserManager <ApplicationUserManager>() .FindById(User.Identity.GetUserId()).Email; Boolean flag = false; int currentDBuserID = -1; string currentDBuserFName = ""; string currentDBuserLName = ""; foreach (var item in db.Customers) { if (item.customerEmail == currentUserEmail) { flag = true; currentDBuserID = item.customerId; currentDBuserFName = item.customerFName; currentDBuserLName = item.customerLName; } } if (flag) { ShoesOrder order = new ShoesOrder(); order.customerId = currentDBuserID; order.comments = currentDBuserLName + " " + currentDBuserFName; return(View(order)); } return(View("")); }
public ActionResult DeleteConfirmed(int id) { ShoesOrder shoesOrder = db.ShoesOrders.Find(id); db.ShoesOrders.Remove(shoesOrder); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "orderId,orderDate,customerId,orderPrice,quantity,shoesName,comments")] ShoesOrder shoesOrder) { if (ModelState.IsValid) { db.Entry(shoesOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.customerId = new SelectList(db.Customers, "customerId", "customerFName", shoesOrder.customerId); return(View(shoesOrder)); }
// GET: ShoesOrders/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShoesOrder shoesOrder = db.ShoesOrders.Find(id); if (shoesOrder == null) { return(HttpNotFound()); } return(View(shoesOrder)); }
// GET: ShoesOrders/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShoesOrder shoesOrder = db.ShoesOrders.Find(id); if (shoesOrder == null) { return(HttpNotFound()); } ViewBag.customerId = new SelectList(db.Customers, "customerId", "customerFName", shoesOrder.customerId); return(View(shoesOrder)); }