コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            CustomerClasses customerClasses = db.CustomerClasses.Find(id);

            db.CustomerClasses.Remove(customerClasses);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 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));
 }
コード例 #3
0
        // 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));
        }
コード例 #4
0
        // 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));
        }
コード例 #5
0
        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));
        }