Esempio n. 1
0
        //public object Utility { get; private set; }

        public ActionResult Profil()
        {
            if (Session["idGosta"] == null)
            {
                RedirectToAction("LogIn", "Registracija");
            }
            else
            {
                string idGosta = Session["idGosta"].ToString();
                GOST   g       = new GOST();
                g = db.GOSTs.Where(z => z.EMAIL_GOSTA == idGosta).Single();
                Restoran.ModelView.Profil prof = new ModelView.Profil();
                prof.adresa  = "Brigadira Ristica c8/5";
                prof.email   = g.EMAIL_GOSTA;
                prof.ime     = g.IME_GOSTA;
                prof.prezime = g.PREZIME_GOSTA;
                var pr = db.PRIJATELJIs.Where(x => x.EMAIL_GOSTA == idGosta).Select(x => x.EMAIL_GOSTA1).ToList();

                prof.prijatelji = new List <GOST>();
                foreach (var item in pr)
                {
                    prof.prijatelji.Add(db.GOSTs.Where(z => z.EMAIL_GOSTA == item).Single());
                }
                return(View(prof));
            }

            return(null);
        }
Esempio n. 2
0
        public ActionResult Edit(ModelView.Profil prof)
        {
            GOST gost = db.GOSTs.Find(prof.Email);

            if (ModelState.IsValid)
            {
                gost.IME_GOSTA       = prof.ime;
                gost.PREZIME_GOSTA   = prof.prezime;
                gost.EMAIL_GOSTA     = prof.Email;
                gost.PASS_GOSTA      = prof.pass;
                gost.CPASS_GOSTA     = prof.cpass;
                db.Entry(gost).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Profil"));
            }

            return(View(gost));
        }
Esempio n. 3
0
        public ActionResult Edit(string id)
        {
            string email = Session["idGosta"].ToString();
            GOST   gost  = db.GOSTs.Find(email);

            if (gost == null)
            {
                return(HttpNotFound());
            }
            ModelView.Profil prof = new ModelView.Profil();
            prof.ime     = gost.IME_GOSTA;
            prof.prezime = gost.PREZIME_GOSTA;
            prof.Email   = gost.EMAIL_GOSTA;
            prof.pass    = gost.PASS_GOSTA;
            prof.cpass   = gost.CPASS_GOSTA;

            return(View(prof));
        }
Esempio n. 4
0
        //
        // GET: /Profil/
        public ActionResult Profil()
        {
            if (Session["idGosta"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                string id = Session["idGosta"].ToString();
                Restoran2016.ModelView.Profil profil = new ModelView.Profil();
                var g = db.GOSTs.Where(x => x.EMAIL_GOSTA == id).Single();

                Restoran2016.ModelView.Profil prof = new ModelView.Profil();
                prof.Email   = id;
                prof.ime     = g.IME_GOSTA;
                prof.prezime = g.PREZIME_GOSTA;
                prof.pass    = g.PASS_GOSTA;
                prof.cpass   = g.CPASS_GOSTA;

                var pr  = db.PRIJATELJIs.Where(z => z.EMAIL_GOSTA1 == id).Select(z => z.EMAIL_GOSTA).ToList(); //lista poslatih zahteva
                var pr2 = db.PRIJATELJIs.Where(z => z.EMAIL_GOSTA == id).Select(z => z.EMAIL_GOSTA1).ToList(); //lista primljenih zahteva
                prof.prijatelji = new List <GOST>();
                var presjek = pr.Select(i => i.ToString()).Intersect(pr2);                                     //prijatelji

                foreach (var item in presjek)
                {
                    prof.prijatelji.Add(db.GOSTs.Where(z => z.EMAIL_GOSTA == item).Single());
                }

                TempData["prijatelji"] = prof.prijatelji;

                var zaht = db.PRIJATELJIs.Where(z => z.EMAIL_GOSTA == id).Where(z => z.EMAIL_GOSTA1 != id).Select(z => z.EMAIL_GOSTA1).ToList();
                prof.zahtevi = new List <GOST>();

                foreach (var item in zaht)
                {
                    prof.zahtevi.Add(db.GOSTs.Where(z => z.EMAIL_GOSTA == item).Single());
                }

                foreach (var item in pr)
                {
                    prof.zahtevi.Remove(db.GOSTs.Where(z => z.EMAIL_GOSTA == item).Single());
                }

                var osim = db.GOSTs.Where(z => z.EMAIL_GOSTA != id).Select(z => z.EMAIL_GOSTA).ToList();
                var npr  = osim.Except(pr);
                prof.neprijatelji = new List <GOST>();
                foreach (var item in npr)
                {
                    prof.neprijatelji.Add(db.GOSTs.Where(z => z.EMAIL_GOSTA == item).Single());
                }

                var rest = db.RESTORANs.Select(z => z.ID_RESTORANA).ToList();
                prof.restorani = new List <RESTORAN>();

                foreach (var item in rest)
                {
                    prof.restorani.Add(db.RESTORANs.Where(z => z.ID_RESTORANA == item).Single());
                }
                ViewBag.restorani = prof.restorani;

                var posete = from y in db.REZERVACIJAs
                             join z in db.RESTORANs on y.ID_RESTORANA equals z.ID_RESTORANA
                             where y.EMAIL_GOSTA == id
                             select new ModelView.RezervisaniRestoran {
                    ID = y.ID, ID_RESTORANA = y.ID_RESTORANA, ID_STOLA = y.ID_STOLA, DATUM = y.DATUM, OCENA = y.OCENA, VREME_DOLASKA = y.VREME_DOLASKA, VREME_ODLASKA = y.VREME_ODLASKA, NAZIV_RESTORANA = z.NAZIV_RESTORANA
                };

                IEnumerable <Restoran2016.ModelView.RezervisaniRestoran> poseteLista = posete;

                var pozivi = from y in db.PRIJATELJI_REZERVACIJA
                             join z in db.REZERVACIJAs on y.ID equals z.ID
                             join x in db.RESTORANs on z.ID_RESTORANA equals x.ID_RESTORANA
                             join w in db.GOSTs on y.EMAIL_GOSTA1 equals w.EMAIL_GOSTA

                             where y.EMAIL_GOSTA == id
                             select new ModelView.PozivRestoran {
                    EMAIL_GOSTA = y.EMAIL_GOSTA, EMAIL_GOSTA1 = y.EMAIL_GOSTA1, ID = z.ID, OCENA = y.OCENA, DATUM = z.DATUM, VREME_DOLASKA = z.VREME_ODLASKA, VREME_ODLASKA = z.VREME_ODLASKA, ID_STOLA = z.ID_STOLA, NAZIV_RESTORANA = x.NAZIV_RESTORANA, IME = w.IME_GOSTA, PREZIME = w.PREZIME_GOSTA
                };

                IEnumerable <Restoran2016.ModelView.PozivRestoran> poziviLista = pozivi;

                var tuple = new Tuple <ModelView.Profil, IEnumerable <Restoran2016.ModelView.RezervisaniRestoran>, IEnumerable <Restoran2016.ModelView.PozivRestoran> >(prof, poseteLista, poziviLista);

                return(View(tuple));
            }
        }