示例#1
0
        public ActionResult Create(Service service)
        {
            if (ModelState.IsValid)
            {
                db.Services.Add(service);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", service.DepartmentID);
            ViewBag.ServerID = new SelectList(db.Servers, "ServerID", "ServerName", service.ServerID);
            return View(service);
        }
示例#2
0
 public ActionResult Edit(Service service)
 {
     if (ModelState.IsValid)
     {
         db.Entry(service).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", service.DepartmentID);
     ViewBag.ServerID = new SelectList(db.Servers, "ServerID", "ServerName", service.ServerID);
     return View(service);
 }