public ActionResult DeleteConfirmed(int id) { CustomerClasses customerClasses = db.CustomerClasses.Find(id); db.CustomerClasses.Remove(customerClasses); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,ClassId,FirstName,LastName,Email,UserId")] CustomerClasses customerClasses) { if (ModelState.IsValid) { db.Entry(customerClasses).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassId = new SelectList(db.Classes, "Id", "Name", customerClasses.ClassId); //ViewBag.UserId = new SelectList(db.ApplicationUsers, "Id", "Email", customerClasses.UserId); return(View(customerClasses)); }
// GET: CustomerClasses/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerClasses customerClasses = db.CustomerClasses.Find(id); if (customerClasses == null) { return(HttpNotFound()); } return(View(customerClasses)); }
// GET: CustomerClasses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerClasses customerClasses = db.CustomerClasses.Find(id); if (customerClasses == null) { return(HttpNotFound()); } ViewBag.ClassId = new SelectList(db.Classes, "Id", "Name", customerClasses.ClassId); //ViewBag.UserId = new SelectList(db.ApplicationUsers, "Id", "Email", customerClasses.UserId); return(View(customerClasses)); }
public ActionResult Create([Bind(Include = "Id,ClassId,FirstName,LastName,Email,UserId")] CustomerClasses customerClasses) { var userId = User.Identity.GetUserId(); var customer = db.Customers.Where(c => c.UserId == userId).Single(); if (ModelState.IsValid) { customerClasses.FirstName = customer.FirstName; customerClasses.LastName = customer.LastName; customerClasses.Email = customer.Email; customerClasses.UserId = customer.UserId; db.CustomerClasses.Add(customerClasses); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassId = new SelectList(db.Classes, "Id", "Name", customerClasses.ClassId); //ViewBag.UserId = new SelectList(db.ApplicationUsers, "Id", "Email", customerClasses.UserId); return(View(customerClasses)); }