public ActionResult Delete([DataSourceRequest] DataSourceRequest request, UserViewModel user)
        {
            if (user != null)
            {
                var u = db.Users.All().First(x => x.Id == user.Id);
                db.Users.Delete(u);
                db.SaveChanges();
            }

            return Json(new[] { user }.ToDataSourceResult(request, ModelState));
        }
        public ActionResult Edit([DataSourceRequest] DataSourceRequest request, UserViewModel user)
        {
            if (user != null && ModelState.IsValid)
            {
                var target = db.Users.All().FirstOrDefault(u => u.Id == user.Id);
                if (target != null)
                {
                    target.UserName = user.UserName;
                    target.FirstName = user.FirstName;
                    target.LastName = user.LastName;
                    target.Email = user.Email;
                    db.Users.Update(target);
                    db.SaveChanges();
                }
            }

            return Json(new[] { user }.ToDataSourceResult(request, ModelState));
        }
        public ActionResult EditRoles(string username)
        {
            var user = db.Users.All().FirstOrDefault(u => u.UserName.ToLower() == username.ToLower());
            if (user == null)
            {
                return HttpNotFound();
            }

            var roles = db.Roles.All().ToList();
            var userRoles = db.UserRoles.All().ToList();
            var userViewModel = new UserViewModel
            {
                Id = user.Id,
                UserName = user.UserName,
                FirstName = user.FirstName,
                LastName = user.LastName,
                Email = user.Email,
                Roles = userRoles.Where(x => x.UserId == user.Id).Select(x => x.Role.Name).ToArray()
            };

            ViewData["roles"] = roles.Select(role => role.Name).ToArray();

            return View(userViewModel);
        }