public IActionResult Registriraj()
        {
            var model = new KlijentRegistrirajVM();

            model.Gradovi = GetGradoviDropdown();
            return(View("Registriraj", model));
        }
        public async Task <IActionResult> Registriraj(KlijentRegistrirajVM model)
        {
            if (!ModelState.IsValid)
            {
                model.Gradovi = GetGradoviDropdown();
                return(View("Registriraj", model));
            }


            var pwValidaton      = new PasswordValidator <Nalog>();
            var validationResult = await pwValidaton
                                   .ValidateAsync(userManager, null, model.Password);

            if (!validationResult.Succeeded)
            {
                foreach (var item in validationResult.Errors.Select(x => x.Description))
                {
                    ModelState.AddModelError("", item);
                }
                model.Gradovi = GetGradoviDropdown();
                return(View("Registriraj", model));
            }


            var postojeciKorisnik = await userManager.FindByNameAsync(model.Username);

            if (postojeciKorisnik != null)
            {
                ModelState.AddModelError("", "Korisnicko ime je zauzeto.");
                model.Gradovi = GetGradoviDropdown();
                return(View("Registriraj", model));
            }

            var noviNalog = new Nalog
            {
                UserName  = model.Username,
                IsKlijent = true
            };

            await userManager.CreateAsync(noviNalog, model.Password);


            Klijent klijent = new Klijent
            {
                Ime     = model.Ime,
                Prezime = model.Prezime,
                GradID  = model.OdabraniGradId,
                JBMG    = model.JBMG,
                UserId  = noviNalog.Id,
                Spol    = model.Spol
            };

            context.Add(klijent);
            context.SaveChanges();



            await signInManager.SignInAsync(noviNalog, true);

            return(RedirectToAction("Index", "Home"));
        }