コード例 #1
0
 public ActionResult Create(Computer newComputer, HttpPostedFileBase file)
 {
     if (ModelState.IsValid)
     {
         newComputer.Photo = "/Images/" + System.IO.Path.GetFileName(file.FileName);
         db.ComputerList.Add(newComputer);
         db.SaveChanges();
         ModelState.AddModelError("", "Add computer completed!");
     }
     return(View());
 }
コード例 #2
0
 public ActionResult Create(User newUser)
 {
     if (ModelState.IsValid)
     {
         newUser.Passcode        = PasscodeSecurity.encPasscode(newUser.Passcode);
         db.Entry(newUser).State = EntityState.Added;
         db.SaveChanges();
         ModelState.AddModelError("", "Add user completed!");
         TempData["Msg"] = "Add user completed!";
     }
     return(View());
 }
コード例 #3
0
 public void Save()
 {
     _context.SaveChanges();
 }