Ejemplo n.º 1
0
        // GET: Aditivi
        public IActionResult Index(string filter)
        {
            var allVrsteAditiva = _repository.GetAllVrsteAditiva();

            ViewData["VrsteAditiva"] = new SelectList(allVrsteAditiva, nameof(VrstaAditiva.VrstaAditivaId), nameof(VrstaAditiva.NazivVrste));

            if (!string.IsNullOrEmpty(filter))
            {
                var upit = _context.Aditiv
                           .Include(a => a.VrstaAditiva)
                           .Include(a => a.PovijestAditiva)
                           .AsNoTracking();

                AditivFilter af = AditivFilter.FromString(filter);

                if (!af.IsEmpty())
                {
                    upit = af.PrimjeniFilter(upit);
                }

                var allAditivi = upit.ToList();

                var model = new AditiviViewModel
                {
                    Aditivi = allAditivi
                };

                return(View(model));
            }
            else
            {
                var allAditivi = _repository.GetAllAditivi();

                var model = new AditiviViewModel
                {
                    Aditivi = allAditivi
                };

                return(View(model));
            }
        }
Ejemplo n.º 2
0
 public IActionResult Filter(AditivFilter filter)
 {
     return(RedirectToAction("Index", new { filter = filter.ToString() }));
 }