Exemple #1
0
 public ActionResult Assign(int?id, device device)
 {
     if (Session["userID"] != null)
     {
         if (ModelState.IsValid)
         {
             db.Entry(device).State = EntityState.Modified;
             var currentDevice = db.devices.Find(id);
             int SessionUserID = (int)Session["userID"];
             currentDevice.UserID = SessionUserID;
             db.SaveChanges();
             return(RedirectToAction("deviceList"));
         }
         return(View(device));
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Exemple #2
0
 public ActionResult Edit([Bind(Include = "userID,userName,password,email,isAdmin,Location,DeviceID")] user user)
 {
     if (Session["userID"] != null && Session["isAdmin"].Equals(true))
     {
         if (ModelState.IsValid)
         {
             db.Entry(user).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.DeviceID = new SelectList(db.devices, "DeviceID", "DName", user.DeviceID);
         return(View(user));
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }