public IActionResult Uredi(int id) { if (HttpContext.Session.GetInt32("user ID") == null) { TempData["poruka"] = poruka; return(Redirect("/Auth/Index")); } if (HttpContext.Session.GetString("role") != "SuperAdmin") { TempData["poruka"] = poruka2; return(Redirect("/Auth/Index")); } else { List <OrganizacionaJedinica> org_jed_lista = db.OrganizacionaJedinica.ToList(); ViewData["org_jed"] = org_jed_lista; ProjekatPlan p = db.ProjekatPlan.Where(a => a.ProjekatPlan_ID == id).FirstOrDefault(); p.organizacionaJedinica = db.OrganizacionaJedinica.Where(a => a.OrganizacionaJedinica_ID == p.OrganizacionaJedinica_FK).FirstOrDefault(); p.status = db.Status.Where(a => a.StatusID == p.Status_FK).FirstOrDefault(); ViewData["projekat"] = p; List <Status> stat_lista = db.Status.ToList(); ViewData["statusi"] = stat_lista; return(View()); } }
public IActionResult Uredi(int id) { if (HttpContext.Session.GetInt32("user ID") == null) { TempData["poruka"] = poruka; return(Redirect("/Auth/Index")); } if (HttpContext.Session.GetString("role") != "Admin-Org-Jed") { TempData["poruka"] = poruka2; return(Redirect("/Auth/Index")); } else { ViewData["logo"] = db.Organizacija.Where(a => a.Organizacija_ID == (int)HttpContext.Session.GetInt32("organisation ID")).Select(o => o.Logo).FirstOrDefault(); ProjekatPlan p = db.ProjekatPlan.Where(a => a.ProjekatPlan_ID == id).FirstOrDefault(); p.organizacionaJedinica = db.OrganizacionaJedinica.Where(a => a.OrganizacionaJedinica_ID == p.OrganizacionaJedinica_FK).FirstOrDefault(); ViewData["projekat"] = p; List <Status> stat_lista = db.Status.ToList(); ViewData["statusi"] = stat_lista; return(View()); } }
public IActionResult UnosSnimi(int organizacionaJedinica, int sifra, string naziv, DateTime Od, DateTime Do, int status_id) { if (HttpContext.Session.GetInt32("user ID") == null) { TempData["poruka"] = poruka; return(Redirect("/Auth/Index")); } if (HttpContext.Session.GetString("role") != "Admin-Org") { TempData["poruka"] = poruka2; return(Redirect("/Auth/Index")); } else { ViewData["logo"] = db.Organizacija.Where(a => a.Organizacija_ID == (int)HttpContext.Session.GetInt32("organisation ID")).Select(o => o.Logo).FirstOrDefault(); ProjekatPlan temp = new ProjekatPlan { DatumDo = Do, DatumOd = Od, Naziv = naziv, OrganizacionaJedinica_FK = organizacionaJedinica, Sifra = sifra, Status_FK = status_id }; db.ProjekatPlan.Add(temp); db.SaveChanges(); List <OrganizacionaJedinica> org_jed_lista = db.OrganizacionaJedinica.Where(a => a.Organizacija_FK == (int)HttpContext.Session.GetInt32("organisation ID")).ToList(); List <ProjekatPlan> pp_temp = db.ProjekatPlan.ToList(); List <ProjekatPlan> pp_final = new List <ProjekatPlan>(); foreach (var x in pp_temp) { foreach (var y in org_jed_lista) { if (x.OrganizacionaJedinica_FK == y.OrganizacionaJedinica_ID) { pp_final.Add(new ProjekatPlan { OrganizacionaJedinica_FK = x.OrganizacionaJedinica_FK, DatumDo = x.DatumDo, DatumOd = x.DatumOd, Naziv = x.Naziv, organizacionaJedinica = db.OrganizacionaJedinica.Where(a => a.OrganizacionaJedinica_ID == x.OrganizacionaJedinica_FK).FirstOrDefault(), ProjekatPlan_ID = x.ProjekatPlan_ID, Sifra = x.Sifra, Status_FK = x.Status_FK, status = db.Status.Where(a => a.StatusID == x.Status_FK).FirstOrDefault() }); } } } ViewData["proj_plan"] = pp_final; return(View("Prikaz")); } }
public IActionResult Uredi(int id) { if (HttpContext.Session.GetInt32("user ID") == null) { TempData["poruka"] = poruka; return(Redirect("/Auth/Index")); } if (HttpContext.Session.GetString("role") != "Admin-Org") { TempData["poruka"] = poruka2; return(Redirect("/Auth/Index")); } else { ViewData["logo"] = db.Organizacija.Where(a => a.Organizacija_ID == (int)HttpContext.Session.GetInt32("organisation ID")).Select(o => o.Logo).FirstOrDefault(); List <OrganizacionaJedinica> lista_org_jed = new List <OrganizacionaJedinica>(); List <OrganizacionaJedinica> org = db.OrganizacionaJedinica.Where(a => a.Organizacija_FK == (int)HttpContext.Session.GetInt32("organisation ID")).ToList(); foreach (var x in org) { if (x.Organizacija_FK == (int)HttpContext.Session.GetInt32("organisation ID")) { lista_org_jed.Add(new OrganizacionaJedinica { Adresa = x.Adresa, drzava = db.Drzava.Where(a => a.Drzava_ID == x.Drzava_FK).FirstOrDefault(), Drzava_FK = x.Drzava_FK, Naziv = db.OrganizacionaJedinica.Where(a => a.Organizacija_FK == (int)HttpContext.Session.GetInt32("organisation ID")).Select(p => p.Naziv).FirstOrDefault(), organizacija = db.Organizacija.Where(a => a.Organizacija_ID == (int)HttpContext.Session.GetInt32("organisation ID")).FirstOrDefault(), Organizacija_FK = x.Organizacija_FK, OrganizacionaJedinica_ID = db.OrganizacionaJedinica.Where(a => a.Organizacija_FK == (int)HttpContext.Session.GetInt32("organisation ID")).Select(p => p.OrganizacionaJedinica_ID).FirstOrDefault(), ptt = db.PTT.Where(a => a.PTT_ID == x.PTT_FK).FirstOrDefault(), PTT_FK = db.PTT.Where(a => a.PTT_ID == x.PTT_FK).Select(p => p.PTT_ID).FirstOrDefault() }); } } ViewData["org_jed"] = org; ProjekatPlan p = db.ProjekatPlan.Where(a => a.ProjekatPlan_ID == id).FirstOrDefault(); p.organizacionaJedinica = db.OrganizacionaJedinica.Where(a => a.OrganizacionaJedinica_ID == p.OrganizacionaJedinica_FK).FirstOrDefault(); ViewData["projekat"] = p; List <Status> stat_lista = db.Status.ToList(); ViewData["statusi"] = stat_lista; return(View()); } }
public IActionResult UnosSnimi(int sifra, string naziv, DateTime Od, DateTime Do, int status_id) { if (HttpContext.Session.GetInt32("user ID") == null) { TempData["poruka"] = poruka; return(Redirect("/Auth/Index")); } if (HttpContext.Session.GetString("role") != "Admin-Org-Jed") { TempData["poruka"] = poruka2; return(Redirect("/Auth/Index")); } else { ViewData["logo"] = db.Organizacija.Where(a => a.Organizacija_ID == (int)HttpContext.Session.GetInt32("organisation ID")).Select(o => o.Logo).FirstOrDefault(); ProjekatPlan temp = new ProjekatPlan { DatumDo = Do, DatumOd = Od, Naziv = naziv, OrganizacionaJedinica_FK = (int)HttpContext.Session.GetInt32("orgJed ID"), Sifra = sifra, Status_FK = status_id }; db.Add(temp); db.SaveChanges(); List <ProjekatPlan> pp_final = db.ProjekatPlan.Where(a => a.OrganizacionaJedinica_FK == (int)HttpContext.Session.GetInt32("orgJed ID")).Include(a => a.organizacionaJedinica).Include(a => a.status).Select(x => new ProjekatPlan { DatumDo = x.DatumDo, DatumOd = x.DatumOd, Naziv = x.Naziv, OrganizacionaJedinica_FK = x.OrganizacionaJedinica_FK, ProjekatPlan_ID = x.ProjekatPlan_ID, Sifra = x.Sifra, organizacionaJedinica = x.organizacionaJedinica, Status_FK = x.Status_FK, status = x.status }).ToList(); ViewData["proj_plan"] = pp_final; return(View("Prikaz")); } }
public IActionResult UnosSnimi(int organizacionaJedinica, int sifra, string naziv, DateTime Od, DateTime Do, int status_id) { if (HttpContext.Session.GetInt32("user ID") == null) { TempData["poruka"] = poruka; return(Redirect("/Auth/Index")); } if (HttpContext.Session.GetString("role") != "SuperAdmin") { TempData["poruka"] = poruka2; return(Redirect("/Auth/Index")); } else { ProjekatPlan temp = new ProjekatPlan { DatumDo = Do, DatumOd = Od, Naziv = naziv, OrganizacionaJedinica_FK = organizacionaJedinica, Sifra = sifra, Status_FK = status_id }; db.ProjekatPlan.Add(temp); db.SaveChanges(); List <ProjekatPlanVM> lista_proj_plan = db.ProjekatPlan.Include(a => a.organizacionaJedinica).Include(a => a.status).Select(x => new ProjekatPlanVM { DatumDo = x.DatumDo, DatumOd = x.DatumOd, Naziv = x.Naziv, OrganizacionaJedinica_id = x.OrganizacionaJedinica_FK, OrganizacionaJedinica_naziv = x.organizacionaJedinica.Naziv, ProjekatPlan_ID = x.ProjekatPlan_ID, Sifra = x.Sifra, Status_id = x.Status_FK, Status_naziv = x.status.Naziv }).ToList(); ViewData["proj_plan"] = lista_proj_plan; return(View("Prikaz")); } }
public IActionResult Ukloni(int id) { if (HttpContext.Session.GetInt32("user ID") == null) { TempData["poruka"] = poruka; return(Redirect("/Auth/Index")); } if (HttpContext.Session.GetString("role") != "SuperAdmin") { TempData["poruka"] = poruka2; return(Redirect("/Auth/Index")); } else { ProjekatPlan temp = db.ProjekatPlan.Where(x => x.ProjekatPlan_ID == id).FirstOrDefault(); if (temp != null) { db.ProjekatPlan.Remove(temp); db.SaveChanges(); } List <ProjekatPlanVM> lista_proj_plan = db.ProjekatPlan.Include(a => a.organizacionaJedinica).Include(a => a.status).Select(x => new ProjekatPlanVM { DatumDo = x.DatumDo, DatumOd = x.DatumOd, Naziv = x.Naziv, OrganizacionaJedinica_id = x.OrganizacionaJedinica_FK, OrganizacionaJedinica_naziv = x.organizacionaJedinica.Naziv, ProjekatPlan_ID = x.ProjekatPlan_ID, Sifra = x.Sifra, Status_id = x.Status_FK, Status_naziv = x.status.Naziv }).ToList(); ViewData["proj_plan"] = lista_proj_plan; return(View("Prikaz")); } }