public JsonResult UpdateUser([DataSourceRequest]
                                      DataSourceRequest request, UserViewModel user)
        {
            var existingUser = this.db.Users.All().FirstOrDefault(u => u.Id == user.Id);

            if (user != null && ModelState.IsValid)
            {
                var hasher = new PasswordHasher();

                existingUser.UserName = user.UserName;
                existingUser.PasswordHash = hasher.HashPassword(user.PasswordHash);
                existingUser.Email = user.Email;
                existingUser.EmailConfirmed = user.EmailConfirmed;
                existingUser.SecurityStamp = Guid.NewGuid().ToString();
                existingUser.CreatedOn = user.CreatedOn;
                existingUser.IsAdmin = user.IsAdmin;

                this.db.SaveChanges();
            }

            return Json((new[] { user }.ToDataSourceResult(request, ModelState)), JsonRequestBehavior.AllowGet);
        }
        public JsonResult CreateUser([DataSourceRequest] DataSourceRequest request, UserViewModel user)
        {
            if (user != null && ModelState.IsValid)
            {
                var hasher = new PasswordHasher();

                var newUser = new ApplicationUser
                {
                    UserName = user.UserName,
                    PasswordHash = hasher.HashPassword(user.PasswordHash),
                    Email = user.Email,
                    EmailConfirmed = user.EmailConfirmed,
                    SecurityStamp = Guid.NewGuid().ToString(),
                    CreatedOn = user.CreatedOn,
                    IsAdmin = user.IsAdmin
                };

                this.db.Users.Add(newUser);
                this.db.SaveChanges();
                user.Id = newUser.Id;
            }

            return Json(new[] { user }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
        }
        public JsonResult DeleteUser([DataSourceRequest]
                                      DataSourceRequest request, UserViewModel user)
        {
            var existingBook = this.db.Users.All().FirstOrDefault(u => u.Id == user.Id);

            this.db.Users.Delete(existingBook);
            this.db.SaveChanges();

            return Json(new[] { user }, JsonRequestBehavior.AllowGet);
        }