public ActionResult ManageUser(ManageUserVM userVM, string roleName, string projects)
        {
            List <Project> oldProjects = projectHelper.ListUserProjects(userVM.UserId).ToList();
            var            oldUser     = db.Users.AsNoTracking().FirstOrDefault(u => u.Id == userVM.UserId);

            var user = db.Users.Find(userVM.UserId);

            user.Email       = userVM.Email;
            user.UserName    = userVM.Email;
            user.FirstName   = userVM.FirstName;
            user.LastName    = userVM.LastName;
            user.PhoneNumber = userVM.PhoneNumber;
            user.AvatarPath  = userVM.AvatarPath;

            if (FileUploadValidator.IsWebFriendlyImage(userVM.Avatar))
            {
                var fileName     = FileStamp.MakeUnique(userVM.Avatar.FileName);
                var serverFolder = WebConfigurationManager.AppSettings["DefaultAvatarFolder"];
                userVM.Avatar.SaveAs(Path.Combine(Server.MapPath(serverFolder), fileName));
                user.AvatarPath = $"{serverFolder}{fileName}";
            }

            db.SaveChanges();
            projectHelper.updateUserProjects(userVM.UserId, userVM.ProjectIds);



            if (roleName != null)
            {
                foreach (var role in roleHelper.ListUserRoles(user.Id))
                {
                    roleHelper.RemoveUserFromRole(user.Id, role);
                }
                if (!string.IsNullOrEmpty(roleName))
                {
                    roleHelper.AddUserToRole(user.Id, roleName);
                }
            }
            var newUser = db.Users.AsNoTracking().FirstOrDefault(u => u.Id == userVM.UserId);

            historyHelper.CheckUserEdits(oldUser, newUser, oldProjects);
            return(RedirectToAction("Index"));
        }