Пример #1
0
 public ActionResult DeleteUser(int id)
 {
     using (var db = new MytubeEntities1())
     {
         var user = db.Users.Find(id);
         user.IsActive = false;
         db.SaveChanges();
         return(View("SaveChangeSuccess"));
     }
 }
Пример #2
0
 public ActionResult SaveEditUser(User model)
 {
     using (var db = new MytubeEntities1())
     {
         var user = db.Users.Find(model.Id);
         user.FirstName    = model.FirstName;
         user.EmailAddress = model.EmailAddress;
         user.Password     = model.Password;
         db.SaveChanges();
         return(Json(new { Success = true }));
     }
 }
Пример #3
0
 public ActionResult AddNewUser(User newUser)
 {
     using (var db = new MytubeEntities1())
     {
         var newUserObject = new User
         {
             EmailAddress = newUser.EmailAddress,
             Password     = newUser.Password,
             FirstName    = newUser.FirstName,
             LastName     = newUser.LastName,
             Username     = newUser.Username,
             RoleId       = 1,
             CreatedOn    = DateTime.Now,
             CreatedBy    = newUser.Username,
             IsActive     = true
         };
         db.Users.Add(newUserObject);
         db.SaveChanges();
         return(Json(new { Success = true }));
     }
 }