public IActionResult Vstavi(string ime, string priimek, string email, string drzava, string geslo, string geslo_ponovi) { // validacija če so vse vnesene in ce sta gesli enaki, TODO pokaze kje je error DALDrzava dz = new DALDrzava(configuration); List <Drzava> d = dz.vrniVseDrzave(); ViewBag.Drzava = d; if (ime == null) { ViewBag.Error = "Ime ne sme biti prazno."; return(View("Registracija")); } if (priimek == null) { ViewBag.Error = "Priimek ne sme biti prazen."; return(View("Registracija")); } if (email == null) { ViewBag.Error = "Email ne sme biti prazen."; return(View("Registracija")); } if (drzava == null) { ViewBag.Error = "Država ne sme biti prazna."; return(View("Registracija")); } if ((geslo == null || geslo_ponovi == null) || (geslo != geslo_ponovi)) { ViewBag.Error = "Gesli se ne ujemata"; return(View("Registracija")); } var regex = @"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"; var match = Regex.Match(geslo, regex, RegexOptions.IgnoreCase); if (!match.Success) { ViewBag.Error = "Geslo mora vsebovati minimalno 8 znakov in 1 številka"; return(View("Registracija")); } DALUporabnik dp = new DALUporabnik(configuration); int id_uporabnika = dp.addUporabnik(ime, priimek, email, drzava, geslo); if (id_uporabnika == -1) { ViewBag.Error = "Uporabnik s tem email naslovom že obstaja"; return(View("Registracija")); } ViewBag.Success = "Registracija uspešna"; return(View("Login")); }
public IActionResult Registracija() { DALDrzava dz = new DALDrzava(configuration); List <Drzava> d = dz.vrniVseDrzave(); ViewBag.Drzava = d; return(View()); }
public IActionResult PosodobiProfil(Uporabnik u, string geslo_ponovi) { if (TempData["ID_uporabnika"] == null) { return(RedirectToAction("Login", "Home")); } DALUporabnik dpp = new DALUporabnik(configuration); int ID_uporabnikaa = Convert.ToInt32(TempData["ID_uporabnika"]); Uporabnik uu = dpp.dobiPodatke(ID_uporabnikaa); DALDrzava dz = new DALDrzava(configuration); List <Drzava> d = dz.vrniVseDrzave(); ViewBag.Drzava = d; ViewBag.Message = uu; if (u.Geslo != null || geslo_ponovi != null) { if (u.Geslo != geslo_ponovi) { ViewBag.Error = "Gesli se ne ujemata"; return(View("Profil")); } var regex = @"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"; var match = Regex.Match(u.Geslo, regex, RegexOptions.IgnoreCase); if (!match.Success) { ViewBag.Error = "Geslo mora vsebovati minimalno 8 znakov in 1 številka"; return(View("Profil")); } } int ID_uporabnika = Convert.ToInt32(TempData["ID_uporabnika"]); TempData.Keep(); DALUporabnik dp = new DALUporabnik(configuration); // todo error če je failov request int ratal = Convert.ToInt32(dp.posodobiUporabnika(ID_uporabnika, u)); ViewBag.Success = "Podatki uspešno posodobljeni"; return(View("Profil")); }
public IActionResult Profil() { if (TempData["ID_uporabnika"] == null) { return(RedirectToAction("Login", "Home")); } int ID_uporabnika = Convert.ToInt32(TempData["ID_uporabnika"]); TempData.Keep(); DALUporabnik dp = new DALUporabnik(configuration); Uporabnik u = dp.dobiPodatke(ID_uporabnika); DALDrzava dz = new DALDrzava(configuration); List <Drzava> d = dz.vrniVseDrzave(); ViewBag.Drzava = d; ViewBag.Message = u; return(View()); }