예제 #1
0
        public ActionResult prijava_prakse(Praksa_student p)
        {
            int broj = (int)Session["UserID"];

            foreach (Praksa_student praksa in baza.PraksaStudent)
            {
                if (praksa.id_student == broj)
                {
                    ViewBag.samojedna = "Mozete imati prijavljenu samo jednu prasku.";
                    return(View());
                }
            }

            Praksa datum = baza.Prakse.SingleOrDefault(s => s.id_praksa == p.id_praksa);


            p.id_student = broj;
            p.datum_do   = datum.datum_do;
            p.datum_od   = datum.datum_od;

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

                return(RedirectToAction("index_student"));
            }
            else
            {
                throw new ArgumentException();
            }
        }
예제 #2
0
        public ActionResult addPraksa(Praksa p)
        {
            baza.Prakse.Add(p);
            baza.SaveChanges();


            return(RedirectToAction("strucna_praksa"));
        }
예제 #3
0
        public ActionResult deletePraksa(int id)
        {
            Praksa praksaToDelete = baza.Prakse.SingleOrDefault(s => s.id_praksa == id);

            baza.Prakse.Remove(praksaToDelete);
            baza.SaveChanges();


            return(RedirectToAction("strucna_praksa"));
        }
예제 #4
0
        public ActionResult editPraksa(int id)
        {
            Session["editPID"] = id;

            Praksa praksaToUpdate = baza.Prakse.SingleOrDefault(s => s.id_praksa == id);

            praksaToUpdate.datum_od = praksaToUpdate.datum_od.Date;
            praksaToUpdate.datum_do = praksaToUpdate.datum_do.Date;
            return(View(praksaToUpdate));
        }
예제 #5
0
        public IActionResult DodajKonkurs(int Id)
        {
            DodajKonkursVM model = new DodajKonkursVM();

            if (Id != 0)
            {
                Praksa p = db.Praksa.Find(Id);
                model.ID          = p.ID;
                model.Naziv       = p.Naziv;
                model.Rok         = p.Rok;
                model.Sadrzaj     = p.Sadrzaj;
                model.Stanje      = p.Stanje;
                model.DatumObjave = p.DatumObjave;
            }
            return(View(model));
        }
예제 #6
0
        public ActionResult editPraksa(Praksa p)
        {
            int studijID = (int)Session["editPID"];

            Praksa praksaToUpdate = baza.Prakse.SingleOrDefault(s => s.id_praksa == studijID);

            praksaToUpdate.id_mentor = p.id_mentor;
            praksaToUpdate.id_studij = p.id_studij;
            praksaToUpdate.datum_od  = p.datum_od;
            praksaToUpdate.datum_do  = p.datum_do;
            praksaToUpdate.naziv     = p.naziv;
            praksaToUpdate.zavrsena  = p.zavrsena;

            baza.SaveChanges();
            Session["editPID"] = null;
            return(RedirectToAction("strucna_praksa"));
        }
예제 #7
0
 public IActionResult PohraniKonkurs(DodajKonkursVM model)
 {
     if (ModelState.IsValid == false)
     {
         return(View("DodajKonkurs", model));
     }
     if (model.Rok.CompareTo(DateTime.Now) <= 0)
     {
         ModelState.AddModelError("", "Datum nije uredan");
         return(View("DodajKonkurs", model));
     }
     if (model.ID == 0)
     {
         Praksa p = new Praksa()
         {
             Naziv       = model.Naziv,
             Rok         = model.Rok,
             Sadrzaj     = model.Sadrzaj,
             DatumObjave = DateTime.Now,
             Stanje      = true
         };
         db.Add(p);
         db.SaveChanges();
     }
     else
     {
         Praksa p = db.Praksa.Find(model.ID);
         p.ID      = model.ID;
         p.Naziv   = model.Naziv;
         p.Sadrzaj = model.Sadrzaj;
         p.Stanje  = model.Stanje;
         p.Rok     = model.Rok;
         db.SaveChanges();
     }
     return(RedirectToAction("ListaKonkursa"));
 }
예제 #8
0
        public async Task <IActionResult> PrikaziKonkurs(int Id)
        {
            Praksa           p     = db.Praksa.Find(Id);
            PrikaziKonkursVM model = new PrikaziKonkursVM()
            {
                ID          = p.ID,
                Naziv       = p.Naziv,
                Sadrzaj     = p.Sadrzaj,
                DatumObjave = p.DatumObjave,
                Rok         = p.Rok.ToString("dd.MM.yyyy  hh:mm"),
                Stanje      = p.Stanje
            };
            var user = await userManager.GetUserAsync(HttpContext.User);

            if (db.konkursPraksa.Where(kp => kp.KonkursID == model.ID).Where(k => k.KorisnikID == user.Id).Any())
            {
                model.VecAplicirao = true;
            }
            else
            {
                model.VecAplicirao = false;
            }
            return(View(model));
        }