public async Task <ActionResult> Edit([Bind(Include = "Id,CustomerId,IsActive,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")] EditUserViewModel applicationUser, params string[] selectedRoles)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser currentUser = await ApplicationUsers.FindAsync(applicationUser.Id);

                currentUser.IsActive        = applicationUser.IsActive;
                db.Entry(currentUser).State = EntityState.Modified;
                await db.SaveChangesAsync();

                var currentRoles = await _applicationUserManager.GetRolesAsync(applicationUser.Id);

                selectedRoles = selectedRoles ?? new string[] { };
                var result = await _applicationUserManager.AddToRolesAsync(applicationUser.Id, selectedRoles.Except(currentRoles).ToArray());

                if (!result.Succeeded)
                {
                    ModelState.AddModelError("", result.Errors.First());
                    return(View());
                }
                result = await _applicationUserManager.RemoveFromRolesAsync(applicationUser.Id, currentRoles.Except(selectedRoles).ToArray());

                if (!result.Succeeded)
                {
                    ModelState.AddModelError("", result.Errors.First());
                    return(View());
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId = new SelectList(db.Customers, "CustomerId", "Name", applicationUser.CustomerId);
            return(View(applicationUser));
        }