Beispiel #1
0
        public ActionResult edit(Objednavka objednavka)
        {
            //PlatetbniMoznostDao platetbniMoznostDao= new PlatetbniMoznostDao();
            //objednavka.Platba = platetbniMoznostDao.GetById(objednavka.Platba.Id);
            //objednavka.Stav = new StavDao().GetById(objednavka.Stav.Id);
            // objednavka.Doprava = new DopravaMoznostDao().GetById(objednavka.Doprava.Id);

            //if (ModelState.IsValid)
            if (ModelState.IsValidField("CenaDopravy") && ModelState.IsValidField("CenaPlatby") && ModelState.IsValidField("CenaCelkem") && ModelState.IsValidField("Adresa.Mesto") && ModelState.IsValidField("Adresa.PSC") && ModelState.IsValidField("Adresa.UliceCP") && ModelState.IsValidField("Adresa.Zeme"))
            {
                ObjednavkaDao objednavkaDao = new ObjednavkaDao();
                AdresaDao     adresaDao     = new AdresaDao();
                adresaDao.Update(objednavka.Adresa);

                objednavkaDao.Update(objednavka);
                return(RedirectToAction("DetailObjednavky", new { id = objednavka.Id }));
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                ViewBag.stavy   = new StavDao().getMezi(false, 1, 7);
                ViewBag.platby  = new PlatetbniMoznostDao().getAktiv(false);
                ViewBag.dopravy = new DopravaMoznostDao().getAktiv(false);
                return(View("EditObjednavky", objednavka));
            }
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        public ActionResult Update(Uzivatel u)
        {
            UzivatelDao ud  = new UzivatelDao();
            AdresaDao   ad  = new AdresaDao();
            PscDao      pd  = new PscDao();
            PSC         psc = pd.FindPsc(u.adresa.psc.psc);

            if (psc != null)
            {
                u.adresa.psc = psc;
            }
            else
            {
                pd.Create(u.adresa.psc);
            }
            Adresa adresa = ad.FindAdresa(u.adresa.mesto, u.adresa.ulice, u.adresa.cp, u.adresa.psc);

            if (adresa != null)
            {
                u.adresa = adresa;
            }
            else
            {
                ad.Create(u.adresa);
            }
            u.prava = u.prava;
            ud.Update(u);
            TempData["x"] = "Profil upraven";
            return(RedirectToAction("Index", "Profil"));
        }
Beispiel #4
0
        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());
        }
Beispiel #5
0
 public KorisnikServis()
 {
     _adresaDao   = new AdresaDao();
     _korisnikDao = new KorisnikDao();
     _rolaDao     = new RolaDao();
 }
Beispiel #6
0
        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"));
        }