public ActionResult DetailUctu() { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLogin(User.Identity.Name); return(View(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 nastaveniUctu() { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLogin(User.Identity.Name); return(PartialView(ucet)); }
public override bool ValidateUser(string username, string password) { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLoginAndPassword(username, password); return(ucet != null); }
public ActionResult SignIn(string login, string password, bool trvale) { MD5 md5 = new MD5CryptoServiceProvider(); Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(password); Byte[] encodedBytes = md5.ComputeHash(originalBytes); password = BitConverter.ToString(encodedBytes); if (Membership.ValidateUser(login, password)) { Ucet ucet = new UcetDao().GetByLoginAndPassword(login, password); if (ucet.Aktivovano == false) { TempData["error"] = "Tento účet není aktivní a nemůže být použit při přihlašování"; return(RedirectToAction("LoginPage")); } if (trvale) { FormsAuthentication.SetAuthCookie(login, true); } else { FormsAuthentication.SetAuthCookie(login, false); } return(RedirectToAction("Index", "Home", new{ area = "" })); } TempData["error"] = "Login nebo heslo jsou špatně"; return(RedirectToAction("LoginPage")); }
public ActionResult nastaveniUctu(int id) { Ucet ucet = new UcetDao().GetById(id); ViewBag.role = new RoleDao().GetlAll(); return(View(ucet)); }
public JsonResult searchUcetbyJmeno(string query) { UcetDao ucetDao = new UcetDao(); IList <Ucet> ucty = ucetDao.SearchJmeno(query); List <String> seznam = (from Ucet u in ucty select u.Jmeno).ToList(); return(Json(seznam, JsonRequestBehavior.AllowGet)); }
public ActionResult Search(string jmeno, string login, string prezdivka, string prijmeni) { int celkem; UcetDao ucetDao = new UcetDao(); IList <Ucet> ucty = ucetDao.Search(jmeno, login, prezdivka, prijmeni, out celkem); ViewBag.celkem = celkem; return(View("Uzivatele", ucty)); }
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 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 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 ActionResult Pridat(int id, int mnozstvi) { if (User.Identity.Name != "") { Ucet ucet = new UcetDao().GetByLogin(User.Identity.Name); PolozkaKosik polozka = new PolozkaKosik(); polozka.Hra = new GameDao().GetById(id); polozka.Aktivovano = true; polozka.IdUser = ucet.Id; polozka.Mnozstvi = mnozstvi; PolozkaKosikDao polozkaKosikDao = new PolozkaKosikDao(); polozkaKosikDao.Create(polozka); } else { if (Request.Cookies["kosik"] == null) { Response.Cookies["kosik"].Value = id + "," + mnozstvi; } else { String x = TNPW.utility.Utilityzer.getCookieValue("kosik"); if (x.Contains(id + "," + mnozstvi) == false) { Response.Cookies["kosik"].Value = Request.Cookies["kosik"].Value + "|" + id + "," + mnozstvi; } else { string objCartListString = Request.Cookies["kosik"].Value.ToString(); string[] objCartListStringSplit = objCartListString.Split('|'); int stare = -1; foreach (string s in objCartListStringSplit) { string[] ss = s.Split(','); if (Convert.ToInt32(ss[0]) == id) { stare = Convert.ToInt32(ss[1]); } break; } int nove = stare + mnozstvi; Response.Cookies["kosik"].Value = Request.Cookies["kosik"].Value.Replace(+id + "," + stare, id + "," + nove); } } Response.Cookies["kosik"].Expires = DateTime.Now.AddDays(7); } return(RedirectToAction("Kosik")); }
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 Uzivatele(int?_page, int?_itemsOnPage, bool?vse, int?showRole) { int celkem; bool _vse = vse.HasValue ? vse.Value : true; int itemsOnPage = _itemsOnPage.HasValue ? _itemsOnPage.Value : Utilityzer.DefaultCountPerPage; int page = _page.HasValue ? _page.Value : 1; int showRol = showRole.HasValue ? showRole.Value : 1;// Boolean jenomAktivni = _jenomAktivni.HasValue ? _jenomAktivni.Value : true; UcetDao ucetDao = new UcetDao(); IList <Ucet> ucty = ucetDao.getPagedByRole(itemsOnPage, showRol, page, out celkem, _vse); ViewBag.pages = (int)Math.Ceiling((double)celkem / (double)itemsOnPage); ViewBag.soucasna = page; ViewBag.vse = vse; ViewBag.perPage = itemsOnPage; ViewBag.celkem = celkem; ViewBag.showRole = showRol; if (Request.IsAjaxRequest()) { return(PartialView("UzivateleAjax", ucty)); } return(View(ucty)); }
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 dokonceniObjednavky(Objednavka model) { PolozkaObjednavkaDao PolozkaObjednavkaDao = new PolozkaObjednavkaDao(); ObjednavkaDao objednavkaDao = new ObjednavkaDao(); AdresaDao adresaDao = new AdresaDao(); Kosik kosik = new Kosik(); if (User.Identity.Name != "") { Ucet 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); } } model.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(); model.Polozky.Add(x); } if (User.Identity.Name != "") { Ucet ucet = new UcetDao().GetByLogin(User.Identity.Name); model.IdUser = ucet.Id; } model.DatumObjednavky = DateTime.Now; model.Stav.Id = 1; adresaDao.Create(model.Adresa); objednavkaDao.Create(model); foreach (PolozkaObjednavka item in model.Polozky) { item.ObjednavkaID = model.Id; PolozkaObjednavkaDao.Create(item); } if (User.Identity.Name != "") { PolozkaKosikDao polozkaKosikDao = new PolozkaKosikDao(); polozkaKosikDao.vyprazdnit(new UcetDao().GetByLogin(User.Identity.Name).Id); } else { if (Request.Cookies["kosik"] == null) { } else { var myCookie = new HttpCookie("kosik"); myCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(myCookie); } } model = objednavkaDao.GetById(model.Id); if (model.Cislo == null) { model.Cislo = DateTime.Now.Day + " " + DateTime.Now.Month + DateTime.Now.Year + "/" + model.Id; } TNPW.utility.Utilityzer.SendingMail(); TempData["error"] = "Objednávka byla vytvořena č." + model.Cislo + ". Na Váš email byl poslán email"; return(View("Zprava")); }
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)); }