public async Task <IActionResult> Edit(string Id)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            var DefaultLanguageID = CurrentUser.DefaultLanguageId;

            var UICustomizationArray = new UICustomization(_context);

            ViewBag.Terms = await UICustomizationArray.UIArray(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), DefaultLanguageID);

            Menus a = new Menus(_context);

            ViewBag.menuItems = await a.TopMenu(DefaultLanguageID);

            var UserFromDb = await _userManager.FindByIdAsync(Id);

            CreateUserViewModel UserToForm = new CreateUserViewModel
            {
                Id                = UserFromDb.Id,
                UserName          = UserFromDb.UserName,
                Email             = UserFromDb.Email,
                DefaultLanguageId = UserFromDb.DefaultLanguageId,
                CountryId         = UserFromDb.CountryId
            };

            var LanguageList    = new List <SelectListItem>();
            var LanguagesFromDb = _context.ZDbLanguageList.FromSql("LanguageSelectAll").ToList();

            foreach (var LanguageFromDb in LanguagesFromDb)
            {
                LanguageList.Add(new SelectListItem
                {
                    Text  = LanguageFromDb.Name,
                    Value = LanguageFromDb.Id.ToString()
                });
            }

            var CountryList     = new List <SelectListItem>();
            var CountriesFromDb = _context.ZDbCountryList.FromSql("CountrySelectAll").ToList();

            foreach (var CountryFromDb in CountriesFromDb)
            {
                CountryList.Add(new SelectListItem
                {
                    Text  = CountryFromDb.Name,
                    Value = CountryFromDb.Id.ToString()
                });
            }

            SuUserAndLists UserAndLists = new SuUserAndLists {
                User = UserToForm, Countries = CountryList, Languages = LanguageList
            };

            return(View(UserAndLists));
        }
        public async Task <IActionResult> Edit(SuUserAndLists FromForm)
        {
            // SuUserModel UpdateUser = new SuUserModel();
            var UserFromDb = await _userManager.FindByIdAsync(FromForm.User.Id);

            UserFromDb.Email              = FromForm.User.Email;
            UserFromDb.NormalizedEmail    = FromForm.User.Email.ToUpper();
            UserFromDb.UserName           = FromForm.User.UserName;
            UserFromDb.NormalizedUserName = FromForm.User.UserName.ToUpper();
            UserFromDb.DefaultLanguageId  = FromForm.User.DefaultLanguageId;
            UserFromDb.CountryId          = FromForm.User.CountryId;
            //  FromForm.User.SecurityStamp = UserFromDb;
            await _userManager.UpdateAsync(UserFromDb);

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create(SuUserAndLists FromForm)
        {
            // SuUserModel UpdateUser = new SuUserModel();
            SuUserModel NewUser = new SuUserModel {
                Email = FromForm.User.Email, UserName = FromForm.User.UserName, DefaultLanguageId = FromForm.User.DefaultLanguageId, CountryId = FromForm.User.CountryId
            };

            NewUser.Email              = FromForm.User.Email;
            NewUser.UserName           = FromForm.User.UserName;
            NewUser.NormalizedEmail    = FromForm.User.Email.ToUpper();
            NewUser.NormalizedUserName = FromForm.User.UserName.ToUpper();
            NewUser.DefaultLanguageId  = FromForm.User.DefaultLanguageId;
            NewUser.CountryId          = FromForm.User.CountryId;
            NewUser.SecurityLevel      = 5;
            await _userManager.CreateAsync(NewUser, FromForm.User.Password);

            return(RedirectToAction("Index"));
        }