public ActionResult Edit(int id)
        {
            User user = userService.GetById(id);

            if (user == null)
            {
                return HttpNotFound();
            }

            MultiSelectList roles = new MultiSelectList(roleService.GetAll().Select(role => role.Name));

            UserEditViewModel userModel = new UserEditViewModel()
            { Id = user.Id, Username = user.Email, Roles = user.Roles.Select(r => r.Name).ToList() };

            ViewBag.Roles = roles;

            return View(userModel);
        }
        public ActionResult Edit(UserEditViewModel userModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    User user = userService.GetById(userModel.Id);

                    if (user != null)
                    {
                        user.Email = userModel.Username;
                        user.Roles = userModel.Roles.Select(s => roleService.GetRoleByName(s)).ToList();
                        userService.Update(user);
                    }
                }
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }