public IActionResult PrikazPlanIProgram(int planID)
        {
            PlanIProgram planIProgram = service.PlanIProgramFind(planID);

            if (planIProgram == null)
            {
                return(View("~/Views/Home/NotFoundAdministracija.cshtml"));
            }
            AdministracijaPrikazPlanIProgramVM model = new AdministracijaPrikazPlanIProgramVM
            {
                ID         = planID,
                Naziv      = planIProgram.Naziv,
                Kategorija = planIProgram.Kategorija.Naziv,
                Opis       = planIProgram.Opis,
                Sedmice    = service.GetSedmiceOrderdByRedniBroj(planID).Select(x => new AdministracijaPrikazPlanIProgramVM.Sedmica
                {
                    RedniBroj = x.RedniBroj,
                    ID        = x.ID,
                    Dani      = service.GetDaniOrderedByRedniBroj(x.ID).Select(y => new AdministracijaPrikazPlanIProgramVM.Dan
                    {
                        ID        = y.ID,
                        RedniBroj = y.RedniBroj
                    }).ToList()
                }).ToList()
            };

            return(View("PrikazPlanIProgram", model));
        }
        public override PlanIProgram GetByID(int id)
        {
            var          plan         = _context.PlanIprogram.Find(id);
            PlanIProgram planIprogram = _mapper.Map <PlanIProgram>(plan);

            planIprogram.Kategorija = _context.PlanKategorija.Where(x => x.Id == planIprogram.KategorijaId).Select(x => x.Naziv).SingleOrDefault();
            return(planIprogram);
        }
Exemplo n.º 3
0
 public DaniPage(PlanIProgram planIProgram)
 {
     InitializeComponent();
     BindingContext = model = new DanViewModel
     {
         PlanIProgram = planIProgram
     };
 }
 public PlanKupovinaPage(PlanIProgram _plan)
 {
     BindingContext = model = new PlanKupovinaViewModel
     {
         PlanIProgram = _plan
     };
     InitializeComponent();
 }
 public PlanDetailsPage(PlanIProgram plan)
 {
     InitializeComponent();
     BindingContext = _model = new PlanDetailsViewModel()
     {
         PlanIProgram = plan
     };
 }
        public bool UniquePlanIProgram(string Naziv)
        {
            PlanIProgram planIProgram = db.PlanIProgram.Where(x => x.Naziv == Naziv && x.Obrisan == false).FirstOrDefault();

            if (planIProgram == null)
            {
                return(true);
            }
            return(false);
        }
        public IActionResult SpremiEditPlanIProgram(AjaxUrediPiPVM model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("~/Ajax/UrediPlanIProgram.cshtml", model));
            }
            PlanIProgram planIProgram = service.PlanIProgramFind(model.ID);

            planIProgram.Opis = model.Opis;
            service.UpdatePlanIProgram(planIProgram);
            return(RedirectToAction("PrikazPlanIProgram", new { planID = model.ID }));
        }
        public IActionResult ObrisiPlanIProgram(int id)
        {
            PlanIProgram planIProgram = service.PlanIProgramFind(id);

            if (planIProgram == null)
            {
                return(View("~/Views/Home/NotFoundAdministracija.cshtml"));
            }
            planIProgram.Obrisan    = true;
            TempData["obrisanPlan"] = planIProgram.Naziv;
            service.UpdatePlanIProgram(planIProgram);
            return(RedirectToAction("PlanIProgramLista"));
        }
Exemplo n.º 9
0
        public IActionResult UrediPlanIProgram(int id)
        {
            PlanIProgram   planIProgram = planIProgramService.PlanIProgramFind(id);
            AjaxUrediPiPVM model        = new AjaxUrediPiPVM
            {
                ID         = planIProgram.ID,
                Kategorija = planIProgram.Kategorija.Naziv,
                Naziv      = planIProgram.Naziv,
                Opis       = planIProgram.Opis
            };

            return(PartialView("UrediPlanIProgram", model));
        }
        public IActionResult SpremiPlanIProgram(AdministracijaDodajPlanIProgramVM model)
        {
            if (!ModelState.IsValid)
            {
                model.Kategorije = service.getKategorije().Select(k => new SelectListItem
                {
                    Value = k.ID.ToString(),
                    Text  = k.Naziv
                }).ToList();
                return(View("DodajPlanIProgram", model));
            }

            PlanIProgram planIProgram = new PlanIProgram
            {
                KategorijaID = model.KategorijaId,
                Naziv        = model.Naziv,
                Opis         = model.Opis
            };

            service.DodajPlanIProgram(planIProgram);

            for (int i = 1; i <= model.BrojSedmica; i++)
            {
                Sedmica sedmica = new Sedmica
                {
                    PlanIProgramID = planIProgram.ID,
                    RedniBroj      = i
                };
                service.DodajSedmicu(sedmica);
                for (int j = 1; j <= 7; j++)
                {
                    Dan dan = new Dan
                    {
                        SedmicaID = sedmica.ID,
                        RedniBroj = j
                    };
                    service.DodajDan(dan);
                }
            }
            return(RedirectToAction("PrikazPlanIProgram", new { planID = planIProgram.ID }));
        }
 public void UpdatePlanIProgram(PlanIProgram planIProgram)
 {
     planIProgramRepository.Update(planIProgram);
 }
 public void DodajPlanIProgram(PlanIProgram planIProgram)
 {
     planIProgramRepository.Add(planIProgram);
 }