// GET: Employee public ActionResult Index() { CustomersEmployeeView customersEmployeeView = new CustomersEmployeeView(); TrashPickUp trashPickUp = new TrashPickUp(); return(View(customersEmployeeView)); }
public ActionResult DeleteConfirmed(int id) { TrashPickUp trashPickUp = db.TrashPickUps.Find(id); db.TrashPickUps.Remove(trashPickUp); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: TrashPickUps/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrashPickUp trashPickUp = db.TrashPickUps.Find(id); if (trashPickUp == null) { return(HttpNotFound()); } return(View(trashPickUp)); }
// GET: TrashPickUps/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrashPickUp trashPickUp = db.TrashPickUps.Find(id); if (trashPickUp == null) { return(HttpNotFound()); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "FirstName", trashPickUp.CustomerID); return(View(trashPickUp)); }
public ActionResult Edit([Bind(Include = "pickUpID,date,dayOfWeek,pickUpCompleted,price,CustomerID")] TrashPickUp trashPickUp) { if (ModelState.IsValid) { db.Entry(trashPickUp).State = EntityState.Modified; if (trashPickUp.pickUpCompleted == true && User.IsInRole("Employee")) { var transactionAmount = trashPickUp.price; var customerBalance = db.TrashPickUps.Where(x => x.CustomerID == trashPickUp.CustomerID).Select(x => x.Customer.paymentBalance).First(); var newCustomerBalance = transactionAmount + customerBalance; var customer = db.TrashPickUps.Where(x => x.pickUpID == trashPickUp.pickUpID).Select(x => x.Customer).First(); customer.paymentBalance = newCustomerBalance; } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(trashPickUp)); }
public ActionResult Create([Bind(Include = "pickUpID,date,dayOfWeek")] TrashPickUp trashPickUp) { string userID = User.Identity.GetUserId(); Customer customer = db.Customers.Where(x => x.userID == userID).Select(x => x).First(); if (ModelState.IsValid) { trashPickUp.CustomerID = customer.ID; db.TrashPickUps.Add(trashPickUp); db.SaveChanges(); if (User.IsInRole("Customer")) { return(RedirectToAction("CustomerPickUps")); } else { return(RedirectToAction("EmployeePickUps")); } } return(View(trashPickUp)); }