public ActionResult nastaveniUctu() { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLogin(User.Identity.Name); return(PartialView(ucet)); }
public ActionResult Edit(Ucet ucet) { ucet.RoleUzivatele = new RoleDao().GetById(ucet.RoleUzivatele.Id); if (ModelState.IsValidField("Jmeno") && ModelState.IsValidField("Prijmeni") && ModelState.IsValidField("Prezdivka") && ModelState.IsValidField("Adresa.Mesto") && ModelState.IsValidField("Email") && ModelState.IsValidField("Telefon") && ModelState.IsValidField("Adresa.PSC") && ModelState.IsValidField("Adresa.UliceCP") && ModelState.IsValidField("Adresa.Zeme") && ModelState.IsValidField("Heslo") && ModelState.IsValidField("Login")) { UcetDao ucetDao = new UcetDao(); AdresaDao adresaDao = new AdresaDao(); MD5 md5 = new MD5CryptoServiceProvider(); Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(ucet.Heslo); Byte[] encodedBytes = md5.ComputeHash(originalBytes); String newpassword = BitConverter.ToString(encodedBytes); ucet.Heslo = newpassword; ucetDao.Update(ucet); adresaDao.Update(ucet.Adresa); TempData["zprava"] = "Editace byla provedena"; return(RedirectToAction("DetailUctu")); } else { TempData["zprava"] = "Editace nebyla provedena. Něco se pokazilo."; return(RedirectToAction("DetailUctu")); } //return Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()); }
public ActionResult DetailUctu() { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLogin(User.Identity.Name); return(View(ucet)); }
public override bool ValidateUser(string username, string password) { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLoginAndPassword(username, password); return(ucet != null); }
public void VyberTest_VybiramZapornouCastku_HaziNonPositiveNumberException() { // arrange Ucet u = new Ucet("Test Case", 15000, 0); float vybrano = -10000; // act u.Vyber(vybrano); }
public void VlozTest_VkladamZapornouCastku_HaziNonPositiveNumberException() { // arrange Ucet u = new Ucet("Test Case", 15000, 0); float vkladano = -10000; // act u.Vloz(vkladano); }
public void VyberTest_VybiramVetsiNezDisponibilniCastku_HaziBalanceViolationException() { // arrange Ucet u = new Ucet("Test Case", 15000, 0); float vybrano = 20000; // act u.Vyber(vybrano); }
public void DisponibilniCastkaTest_ZustatekAKontokorent_VraciSoucetZustatekAKontokorent() { // arrange Ucet u = new Ucet("Test Case", 10000, 5000); float ocekavano = 15000; // act float vysledek = u.DisponibilniCastka(); // assert Assert.AreEqual(ocekavano, vysledek); }
public override string[] GetRolesForUser(string username) { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLogin(username); if (ucet == null) { return(new string[] {}); } return(new string[] { ucet.RoleUzivatele.Identifikator }); }
public ActionResult prehledObjednavek() { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLogin(User.Identity.Name); ObjednavkaDao objednavkaDao = new ObjednavkaDao(); IList <Objednavka> objednavky = objednavkaDao.GetByUzivatel(ucet.Id); ucet.Objednavky = objednavky; return(PartialView(objednavky)); }
public override bool IsUserInRole(string username, string roleName) { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLogin(username); if (ucet == null) { return(false); } return(ucet.RoleUzivatele.Identifikator == roleName); }
public void VyberTest_KladnaCastkaMensiNezDisponibilni_SniziSeZustatek() { // arrange Ucet u = new Ucet("Test Case", 15000, 0); float vybrano = 10000; float ocekavano = 5000; // act u.Vyber(vybrano); float vysledek = u.Zustatek; // assert Assert.AreEqual(ocekavano, vysledek); }
public void VlozTest_VkladamKladnouCastku_NavysiSeZustatek() { // arrange Ucet u = new Ucet("Test Case", 15000, 0); float vkladano = 10000; float ocekavano = 25000; // act u.Vloz(vkladano); float vysledek = u.Zustatek; // assert Assert.AreEqual(ocekavano, vysledek); }
public ActionResult DetailUzivatele(int id) { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetById(id); ObjednavkaDao objednavkaDao = new ObjednavkaDao(); IList <Objednavka> objednavky = objednavkaDao.GetByUzivatel(ucet.Id); ucet.Objednavky = objednavky; foreach (Objednavka objednavka in ucet.Objednavky) { PolozkaObjednavkaDao polozkaObjednavkaDao = new PolozkaObjednavkaDao(); IList <PolozkaObjednavka> polozky = polozkaObjednavkaDao.getbyObjednavka(objednavka.Id); objednavka.Polozky = polozky; } ; return(View(ucet)); }
public ActionResult registrovat(string log, string password, Ucet ucet) { if (!new UcetDao().IsThereLogin(log)) { ucet.Login = log; ucet.Heslo = password; if (ModelState.IsValidField("Jmeno") && ModelState.IsValidField("Prijmeni") && ModelState.IsValidField("Prezdivka") && ModelState.IsValidField("Adresa.Mesto") && ModelState.IsValidField("Email") && ModelState.IsValidField("Telefon") && ModelState.IsValidField("Adresa.PSC") && ModelState.IsValidField("Adresa.UliceCP") && ModelState.IsValidField("Adresa.Zeme") && ModelState.IsValidField("Heslo") && ModelState.IsValidField("Login")) { ucet.RoleUzivatele = new RoleDao().GetById(1); ucet.Aktivovano = true; UcetDao ucetDao = new UcetDao(); AdresaDao adresaDao = new AdresaDao(); MD5 md5 = new MD5CryptoServiceProvider(); Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(password); Byte[] encodedBytes = md5.ComputeHash(originalBytes); String newpassword = BitConverter.ToString(encodedBytes); ucet.Heslo = newpassword; adresaDao.Create(ucet.Adresa); ucetDao.Create(ucet); TempData["succes"] = "Registrace byla provedena. Nyní se můžete přihlásit"; return(RedirectToAction("LoginPage", "Login")); } else { TempData["zprava"] = "Registrace nebyla provedena. Něco se pokazilo."; return(View("Registrace", ucet)); } } else { TempData["zprava"] = "Tento login už je v eshopu používán"; return(View("Registrace", ucet)); } //return Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()); }
public ActionResult aktivace2(string _id) { int id = int.Parse(_id); UcetDao ucetdao = new UcetDao(); Ucet ucet = ucetdao.GetById(id); if (ucet.Aktivovano) { ucet.Aktivovano = false; } else { ucet.Aktivovano = true; } ucetdao.Update(ucet); return(RedirectToAction("DetailUzivatele", new { id = id })); }
public ActionResult aktivace(int?_page, int?_itemsOnPage, bool?vse, int?showRole, string _id) { int id = int.Parse(_id); UcetDao ucetdao = new UcetDao(); Ucet ucet = ucetdao.GetById(id); if (ucet.Aktivovano) { ucet.Aktivovano = false; } else { ucet.Aktivovano = true; } ucetdao.Update(ucet); return(RedirectToAction("Uzivatele", new { _page = _page, vse = vse, _itemsOnPage = _itemsOnPage, showRole = showRole })); }
public ActionResult zmenaHesla(string pasOld, string pasNew, string pasNewNew) { UcetDao ucetDao = new UcetDao(); MD5 md5 = new MD5CryptoServiceProvider(); Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(pasOld); Byte[] encodedBytes = md5.ComputeHash(originalBytes); pasOld = BitConverter.ToString(encodedBytes); if (pasNew == pasNewNew) { try { Ucet ucet = ucetDao.GetByLoginAndPassword(User.Identity.Name, pasOld); if (ucet.Heslo == pasOld) { md5 = new MD5CryptoServiceProvider(); originalBytes = ASCIIEncoding.Default.GetBytes(pasNew); encodedBytes = md5.ComputeHash(originalBytes); String newpassword = BitConverter.ToString(encodedBytes); ucet.Heslo = newpassword; ucetDao.Update(ucet); TempData["zprava"] = "Změna hesla byla provedena."; return(RedirectToAction("DetailUctu")); } } catch (Exception e) { TempData["zprava"] = "Staré heslo nesouhlasí"; return(RedirectToAction("DetailUctu")); } } TempData["zprava"] = "Změna hesla nebyla provede. Nové heslo a potvrzení nového hesla není stejné"; return(RedirectToAction("DetailUctu")); }
public ActionResult Kosik() { PlatetbniMoznostDao platetbniMoznostDao = new PlatetbniMoznostDao(); IList <PlatetbniMoznost> platba = platetbniMoznostDao.getAktiv(false); DopravaMoznostDao dopravaMoznostDao = new DopravaMoznostDao(); IList <DopravaMoznost> doprava = dopravaMoznostDao.getAktiv(false); Ucet ucet = new Ucet(); foreach (DopravaMoznost item in doprava) { item.Nazev = item.Nazev + " " + item.Cena + " Kč"; } foreach (PlatetbniMoznost item in platba) { item.Nazev = item.Nazev + " " + item.Cena + " Kč"; } ViewBag.platby = platba; ViewBag.doprava = doprava; if (User.Identity.Name != "") { ucet = new UcetDao().GetByLogin(User.Identity.Name); IList <PolozkaKosik> polozky = new PolozkaKosikDao().GetByUzivatel(ucet.Id); Kosik kosik = new Kosik(polozky); @ViewBag.Jmeno = ucet.Jmeno; @ViewBag.Prijmeni = ucet.Prijmeni; @ViewBag.Telefon = ucet.Telefon; @ViewBag.Email = ucet.Email; @ViewBag.uzivatel = ucet.Id; @ViewBag.Mesto = ucet.Adresa.Mesto; @ViewBag.PSC = ucet.Adresa.PSC; @ViewBag.UliceCP = ucet.Adresa.UliceCP; @ViewBag.Zeme = ucet.Adresa.Zeme; kosik.vymazani(); return(View(kosik)); } else { if (Request.Cookies["kosik"] != null) { string objCartListString = Request.Cookies["kosik"].Value.ToString(); string[] objCartListStringSplit = objCartListString.Split('|'); IList <PolozkaKosik> polozky = new List <PolozkaKosik>(); foreach (string s in objCartListStringSplit) { PolozkaKosik polozka = new PolozkaKosik(); string[] ss = s.Split(','); polozka.Hra = new GameDao().GetById(Convert.ToInt32(ss[0])); polozka.Mnozstvi = Convert.ToInt32(ss[1]); polozky.Add(polozka); } Kosik kosik = new Kosik(polozky); @ViewBag.Jmeno = ucet.Jmeno; @ViewBag.Prijmeni = ucet.Prijmeni; @ViewBag.Telefon = ucet.Telefon; @ViewBag.Email = ucet.Email; @ViewBag.uzivatel = ucet.Id; @ViewBag.Mesto = ucet.Adresa.Mesto; @ViewBag.PSC = ucet.Adresa.PSC; @ViewBag.UliceCP = ucet.Adresa.UliceCP; @ViewBag.Zeme = ucet.Adresa.Zeme; return(View(kosik)); } else { Kosik kosik = new Kosik(); @ViewBag.Jmeno = ucet.Jmeno; @ViewBag.Prijmeni = ucet.Prijmeni; @ViewBag.Telefon = ucet.Telefon; @ViewBag.Email = ucet.Email; @ViewBag.uzivatel = ucet.Id; @ViewBag.Mesto = ucet.Adresa.Mesto; @ViewBag.PSC = ucet.Adresa.PSC; @ViewBag.UliceCP = ucet.Adresa.UliceCP; @ViewBag.Zeme = ucet.Adresa.Zeme; kosik.vymazani(); return(View(kosik)); } } }
public ActionResult vytvoritObjednavku(int?uzivatel, int platba, int doprava, string jmeno, string prijmeni, string email, string telefon, string mesto, string ulice, string psc, string zeme) { Objednavka o = new Objednavka(); o.Adresa = new Adresa(); o.Adresa.Aktivovano = true; o.Adresa.Mesto = mesto; o.Adresa.PSC = psc; o.Adresa.UliceCP = ulice; o.Adresa.Zeme = zeme; o.Aktivovano = true; o.DatumObjednavky = DateTime.Now; o.Doprava = new DopravaMoznostDao().GetById(doprava); o.Platba = new PlatetbniMoznostDao().GetById(platba); o.Jmeno = jmeno; o.Prijmeni = prijmeni; o.Telefon = telefon; o.Email = email; if (uzivatel != null) { o.IdUser = (int)uzivatel; } Kosik kosik = new Kosik(); Ucet ucet = new Ucet(); if (User.Identity.Name != "") { ucet = new UcetDao().GetByLogin(User.Identity.Name); IList <PolozkaKosik> polozky = new PolozkaKosikDao().GetByUzivatel(ucet.Id); kosik = new Kosik(polozky); } else { if (Request.Cookies["kosik"] != null) { string objCartListString = Request.Cookies["kosik"].Value.ToString(); string[] objCartListStringSplit = objCartListString.Split('|'); IList <PolozkaKosik> polozky = new List <PolozkaKosik>(); foreach (string s in objCartListStringSplit) { PolozkaKosik polozka = new PolozkaKosik(); string[] ss = s.Split(','); polozka.Hra = new GameDao().GetById(Convert.ToInt32(ss[0])); polozka.Mnozstvi = Convert.ToInt32(ss[1]); polozky.Add(polozka); } kosik = new Kosik(polozky); } } o.Polozky = new List <PolozkaObjednavka>(); foreach (PolozkaKosik item in kosik.Polozky) { PolozkaObjednavka x = new PolozkaObjednavka(); x.Hra = item.Hra; x.Aktivovano = true; x.Mnozstvi = item.Mnozstvi; x.Stav = new Stav(); x.Stav.Id = 8; x.TehdejsiCena = item.Hra.aktualniCenasDPH(); o.Polozky.Add(x); } o.prepocet(); @ViewBag.Jmeno = ucet.Jmeno; @ViewBag.Prijmeni = ucet.Prijmeni; @ViewBag.Telefon = ucet.Telefon; @ViewBag.Email = ucet.Email; @ViewBag.uzivatel = ucet.Id; @ViewBag.Mesto = ucet.Adresa.Mesto; @ViewBag.PSC = ucet.Adresa.PSC; @ViewBag.UliceCP = ucet.Adresa.UliceCP; @ViewBag.Zeme = ucet.Adresa.Zeme; return(View(o)); }
public ActionResult createUcet(Ucet novyUcet) { return(RedirectToAction("LoginPage", "Login")); }