public ActionResult <IEnumerable <Zadatak> > Get() { var zadaci = _service.GetAll().ToList(); var zadaciDTO = _mapper.Map <IEnumerable <ZadatakDTO> >(zadaci); return(Ok(zadaciDTO)); }
public IActionResult Index(string message) { try { ViewBag.ListaAngazovanja = service.GetAll().ToList(); List <Zadatak> zadaci = serviceZadaci.GetAll().Distinct(new ZadatakComparer()).ToList(); ViewBag.ListaZadataka = zadaci; if (message == null) { message = string.Empty; } ViewBag.Message = message; return(View()); } catch (Exception ex) { return(RedirectToAction("Error", "Home", new { message = ex.Message })); } }
public IActionResult Index(string message) { try { if (message == null) { message = string.Empty; } List <Zadatak> zadaci = service.GetAll().ToList(); foreach (Zadatak z in zadaci) { if (z.Datum <= DateTime.Now && z.Status == "Kreiran") { Zadatak zadatakIzBaze = service.FindById(z.Id); if (zadatakIzBaze == null) { return(RedirectToAction("PageNotFound", "Home", new { message = "Zadatak čije podatke zahtevate ne postoji!" })); } zadatakIzBaze.Angazovanja = z.Angazovanja; zadatakIzBaze.Datum = z.Datum; zadatakIzBaze.NazivZadatka = z.NazivZadatka; zadatakIzBaze.Teren = z.Teren; zadatakIzBaze.Status = Enumerations.Status.Završen.ToString(); service.Update(zadatakIzBaze); } int i = 0; foreach (Angazovanje a in z.Angazovanja) { if (a.Ocena != null) { i++; } } if (i == z.Angazovanja.Count() && z.Status != "Ocenjen") { Zadatak zadatakIzBaze = service.FindById(z.Id); if (zadatakIzBaze == null) { return(RedirectToAction("PageNotFound", "Home", new { message = "Zadatak čije podatke zahtevate ne postoji!" })); } zadatakIzBaze.Angazovanja = z.Angazovanja; zadatakIzBaze.Datum = z.Datum; zadatakIzBaze.NazivZadatka = z.NazivZadatka; zadatakIzBaze.Teren = z.Teren; zadatakIzBaze.Status = Enumerations.Status.Ocenjen.ToString(); service.Update(zadatakIzBaze); } } ViewBag.ListaZadataka = service.GetAll().ToList(); List <string> naziviZadataka = service.VratiListuNazivaZadataka(); List <int> ang = service.VratiBrojAngazovanjaPoZadatku(); List <int> poz = service.VratiBrojPozitivihOcenaPoZadatku(); ViewBag.Message = message; List <DataPoint> dataPoints1 = new List <DataPoint>(); List <DataPoint> dataPoints2 = new List <DataPoint>(); for (int i = 0; i < naziviZadataka.Count(); i++) { if (zadaci.ElementAt(i).Status == "Ocenjen") { dataPoints1.Add(new DataPoint(zadaci.ElementAt(i).NazivZadatka, poz.ElementAt(i))); } } for (int i = 0; i < naziviZadataka.Count(); i++) { if (zadaci.ElementAt(i).Status == "Ocenjen") { dataPoints2.Add(new DataPoint(zadaci.ElementAt(i).NazivZadatka, ang.ElementAt(i))); } } ViewBag.DataPoints1 = JsonConvert.SerializeObject(dataPoints1); ViewBag.DataPoints2 = JsonConvert.SerializeObject(dataPoints2); return(View()); } catch (Exception ex) { return(RedirectToAction("Error", "Home", new { message = ex.Message })); } }