示例#1
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         userCollection.SaveUser(user);
         TempData["message"] = string.Format("User {0} has been saved", user.Name);
         return RedirectToAction("UserList");
     }
     else
     {
         return View(user);
     }
 }
示例#2
0
 public void SaveUser(User user)
 {
     if (user.Id == 0)
     {
         userContext.Add(user);
     }
     else
     {
         User dbEntry = userContext.Find(m => m.Id == user.Id);
         if (dbEntry != null)
         {
             dbEntry.Login = user.Login;
             dbEntry.Name = user.Name;
             dbEntry.Password = user.Password;
             dbEntry.Role = user.Role;
         }
     }
 }