Exemple #1
0
        public ActionResult DodavanjePoduzeca(Poduzece p)
        {
            if (ModelState.IsValid)
            {
                if (p.id_poduzece != 0)
                {
                    // ažuriranje

                    baza.Entry(p).State =
                        EntityState.Modified;
                }
                else
                {
                    // upis
                    baza.Poduzeca.Add(p);
                }

                baza.SaveChanges();

                return(RedirectToAction("Popis"));
            }
            List <Poduzece> poduzece = baza.Poduzeca.ToList();

            poduzece.Add(new Poduzece {
                naziv_poduzece = "Nedefinirano"
            });
            ViewBag.Poduzece = poduzece;
            ViewBag.Title    = "Dodavanje novog poduzeca";
            return(View(p));
        }
Exemple #2
0
        public ActionResult UrediPoduzece([Bind(Include = "id_poduzece, naziv_poduzece,adresa, grad, telefon, email, web_adresa")] Poduzece pod)
        {
            if (!ModelState.IsValid)
            {
                return(View("UrediPoduzece", pod));
            }

            Poduzece P = baza.Poduzeca.Where(

                x => x.id_poduzece == pod.id_poduzece).SingleOrDefault();

            if (pod.id_poduzece != 0 && P != null)
            {
                baza.Entry(P).CurrentValues.SetValues(pod);
            }
            else
            {
                baza.Poduzeca.Add(pod);
            }
            baza.SaveChanges();
            if (Request.IsAjaxRequest())
            {
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            return(RedirectToAction("Popis"));
        }
Exemple #3
0
        public ActionResult DodavanjePoduzeca(int?id)
        {
            Poduzece p;

            if (id == null)
            {
                p = new Poduzece();
            }
            else
            {
                p = baza.Poduzeca.Find(id);
                if (p == null)
                {
                    return(HttpNotFound());
                }
            }

            List <Poduzece> poduzece = baza.Poduzeca.ToList();

            poduzece.Add(new Poduzece {
                naziv_poduzece = "Nedefinirano"
            });
            ViewBag.Poduzece = poduzece;
            ViewBag.Title    = "Dodavanje novog poduzeca";
            return(View(p));
        }
Exemple #4
0
        public ActionResult editPoduzeca(int id)
        {
            Poduzece poduzeceToUpdate = baza.Poduzeca.SingleOrDefault(s => s.id_poduzece == id);

            Session["editPod"] = id;
            return(View(poduzeceToUpdate));
        }
Exemple #5
0
        public ActionResult UrediPoduzece(int id)
        {
            Poduzece p = new Poduzece();

            foreach (Poduzece pod in baza.Poduzeca)
            {
                if (pod.id_poduzece == id)
                {
                    p = pod;
                }
            }

            if (p == null)
            {
                return(HttpNotFound());
            }
            if (Request.IsAjaxRequest())

            {
                ViewBag.IsUpdate = false;

                return(View("UrediPoduzece", p));
            }
            else
            {
                return(View("UrediPoduzece", p));
            }
        }
Exemple #6
0
        public ActionResult detailsPoduzeca(int id)
        {
            Poduzece        poduzeceToUpdate = baza.Poduzeca.SingleOrDefault(s => s.id_poduzece == id);
            List <Poduzece> lista            = new List <Poduzece>();

            lista.Add(poduzeceToUpdate);
            return(View(lista));
        }
Exemple #7
0
        public ActionResult deletePoduzeca(int id)
        {
            Poduzece poduzeceToDelete = baza.Poduzeca.SingleOrDefault(s => s.id_poduzece == id);

            baza.Poduzeca.Remove(poduzeceToDelete);
            baza.SaveChanges();


            return(RedirectToAction("poduzeca"));
        }
Exemple #8
0
        public ActionResult prijava_studenta(Poduzece p)
        {
            List <Praksa> listaPrkse = baza.Prakse.ToList();

            if (ModelState.IsValid)
            {
                baza.Poduzeca.Add(p);
                baza.SaveChanges();

                return(RedirectToAction("index_student"));
            }

            return(View());
        }
Exemple #9
0
        public ActionResult ObrisiPoduzece(int id)
        {
            Poduzece pod = baza.Poduzeca.Find(id);

            if (Request.IsAjaxRequest())
            {
                ViewBag.IsUpdate = false;
                return(View("ObrisiPoduzece", pod));
            }
            else
            {
                return(View("ObrisiPoduzece", pod));
            }
        }
Exemple #10
0
        public ActionResult addPoduzece(Poduzece p)
        {
            List <Praksa> listaPrkse = baza.Prakse.ToList();

            if (ModelState.IsValid)
            {
                baza.Poduzeca.Add(p);
                baza.SaveChanges();

                return(RedirectToAction("index_admin"));
            }
            else
            {
                return(View(p));
            }
        }
Exemple #11
0
        public ActionResult ObrisiPoduzece1(int id)
        {
            Poduzece P = baza.Poduzeca.Where(
                x => x.id_poduzece == id).SingleOrDefault();

            if (P != null)
            {
                baza.Poduzeca.Remove(P);
                baza.SaveChanges();
            }
            if (Request.IsAjaxRequest())
            {
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }

            return(RedirectToAction("Popis"));
        }
Exemple #12
0
        public ActionResult editPoduzeca(Poduzece p)
        {
            if (ModelState.IsValid)
            {
                int      broj             = (int)Session["editPod"];
                Poduzece poduzeceToUpdate = baza.Poduzeca.SingleOrDefault(s => s.id_poduzece == broj);
                poduzeceToUpdate.naziv         = p.naziv;
                poduzeceToUpdate.adresa        = p.adresa;
                poduzeceToUpdate.URL           = p.URL;
                poduzeceToUpdate.email         = p.email;
                poduzeceToUpdate.grad          = p.grad;
                poduzeceToUpdate.kontakt_osoba = p.kontakt_osoba;
                poduzeceToUpdate.opis          = p.opis;
                poduzeceToUpdate.tel           = p.tel;

                baza.SaveChanges();
                Session["editPod"] = null;
                return(RedirectToAction("poduzeca"));
            }
            else
            {
                return(View(p));
            }
        }
Exemple #13
0
        public ActionResult prijava_studenta()
        {
            Poduzece p = new Poduzece();

            return(View(p));
        }
Exemple #14
0
        public ActionResult addPoduzece()
        {
            Poduzece p = new Poduzece();

            return(View(p));
        }