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(); } }
public ActionResult addPraksa(Praksa p) { baza.Prakse.Add(p); baza.SaveChanges(); return(RedirectToAction("strucna_praksa")); }
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")); }
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)); }
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)); }
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")); }
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")); }
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)); }