Example #1
0
        public ActionResult Index()
        {
            Uzivatel          u         = new UzivatelDao().GetByLogin(User.Identity.Name);
            RezervaceDao      rd        = new RezervaceDao();
            IList <Rezervace> rezervace = rd.GetByUser(u.Id);

            return(View(rezervace));
        }
Example #2
0
        public ActionResult Detail(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }
            Uzivatel     u  = new UzivatelDao().GetById(id.Value);
            RezervaceDao rd = new RezervaceDao();

            ViewBag.Rezervace = rd.GetByUser(u.Id);
            return(View(u));
        }
Example #3
0
        public ActionResult Delete(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index", "Zajezdy"));
            }

            HotelDao       hd = new HotelDao();
            Hotel          h  = hd.GetById(id.Value);
            ZajezdDao      zd = new ZajezdDao();
            RezervaceDao   rd = new RezervaceDao();
            IList <Zajezd> z  = zd.GetByHotel(h.Id);

            if (z.Count() > 0)
            {
                foreach (Zajezd r in z)
                {
                    IList <Rezervace> rezervace = rd.GetByZajezd(r.Id);
                    if (rezervace.Count() > 0)
                    {
                        foreach (Rezervace rez in rezervace)
                        {
                            rd.Delete(rez);
                        }
                    }
                    zd.Delete(r);
                }
            }
            if (h.fotky.Count > 0)
            {
                FotografieDao fd = new FotografieDao();
                foreach (Fotografie f in h.fotky)
                {
                    System.IO.File.Delete(Server.MapPath(f.fotografie));
                    System.IO.File.Delete(Server.MapPath(f.nahled));
                    fd.Delete(f);
                }
            }

            hd.Delete(h);


            TempData["x"] = "Hotel úspěšně smazán";


            return(RedirectToAction("Index", "Zajezdy"));
        }
Example #4
0
        public ActionResult Smaz(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }
            RezervaceDao rd = new RezervaceDao();
            Rezervace    r  = rd.GetById(id.Value);
            Zajezd       z  = r.zajezd;


            MailClient.sendMail(r.uzivatel.login, "Zrušení rezervace zájezdu", "Vážený zákazníku, vaše rezervace byla zrušena.");

            int pocet = r.pocetDeti + r.pocetDospelych;

            z.kapacita = z.kapacita + pocet;
            rd.Update(r);
            rd.Delete(r);

            return(RedirectToAction("Detail", "Uzivatele", new { id = r.uzivatel.Id }));
        }
Example #5
0
        public ActionResult Rezervovat(Rezervace r, int?zi)
        {
            if (!zi.HasValue)
            {
                return(RedirectToAction("Index"));
            }
            ZajezdDao zj = new ZajezdDao();
            Zajezd    z  = zj.GetById(zi.Value);

            r.zajezd = z;
            RezervaceDao rd    = new RezervaceDao();
            int          pocet = r.pocetDeti + r.pocetDeti;

            if (pocet > r.zajezd.kapacita)
            {
                TempData["Rezervace"] = "Omlouváme se, ale nepodařilo se vytvořit rezervaci z důvodu nedostatečné kapacity";
                return(RedirectToAction("Detail", "Zajezdy", z.hotel.Id));
            }
            UzivatelDao ud       = new UzivatelDao();
            Uzivatel    uzivatel = ud.GetByLogin(User.Identity.Name);
            int         kap      = r.zajezd.kapacita - pocet;

            z.kapacita = kap;
            r.uzivatel = uzivatel;
            rd.Create(r);
            zj.Update(r.zajezd);
            IList <Uzivatel> uzivatele = new UzivatelDao().GetUsersNotInRole(new UzivatelskaPravaDao().GetById(2));

            foreach (Uzivatel u in uzivatele)
            {
                MailClient.sendMail(u.login, "Vytvořená nová rezervace", "Vážený zaměstnanče, byla vytvořena nová rezervace od uživatele" + r.uzivatel.jmeno + " " + r.uzivatel.prijmeni + ".");
            }

            TempData["Rezervace"] = "Rezervace proběhla úspěšně";
            return(RedirectToAction("Index", "Zajezdy"));
        }
Example #6
0
        public ActionResult Smaz(int?z)
        {
            if (!z.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            RezervaceDao      rd        = new RezervaceDao();
            ZajezdDao         zd        = new ZajezdDao();
            Zajezd            zaj       = zd.GetById(z.Value);
            Hotel             hotel     = zaj.hotel;
            IList <Rezervace> rezervace = rd.GetByZajezd(zaj.Id);

            if (rezervace.Count() > 0)
            {
                foreach (Rezervace r in rezervace)
                {
                    rd.Delete(r);
                }
            }
            zd.Delete(zaj);
            TempData["x"] = "Zájezd smazán";
            return(View("Detail", hotel));
        }
Example #7
0
        public ActionResult Rezervuj(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }
            RezervaceDao rd = new RezervaceDao();
            Rezervace    r  = rd.GetById(id.Value);

            MailClient.sendMail(r.uzivatel.login, "Potvrzení rezervace zájezdu", "Vážený zákazníku, vaše rezervace byla úspěšně evidována jako zaplacená.");
            string deti = ".";

            if (r.pocetDeti > 0)
            {
                deti = "a pro" + r.pocetDeti + " dětí.";
            }
            MailClient.sendMail(r.zajezd.hotel.email, "Rezervace zájezdu", "Na váš hotel" + r.zajezd.hotel.nazev + " byla vytvořena rezervace pro" + r.pocetDospelych + " dospělých osob" + deti);


            r.zaplaceno = true;
            rd.Update(r);

            return(RedirectToAction("Detail", "Uzivatele", new { id = r.uzivatel.Id }));
        }