예제 #1
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(user);
        }
예제 #2
0
        public void SaveUser(User user)
        {
            if (user.UserId == 0)
            {

                _context.Users.Add(user);
            }
            else
            {
                _context.Users.Attach(user);
                _context.Entry<User>(user).State = System.Data.EntityState.Modified;
            }

            _context.SaveChanges();
        }
예제 #3
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index","Home");
     }
     return View(user);
 }
 public UserActivityViewModel(IEnumerable<User> users, IEnumerable<Activity> activities, User currentUser)
 {
     Users = users;
     Activities = activities;
     CurrentUser = currentUser;
 }