public IActionResult Index(string pretraga) { PrikaziOpremuVM Model = new PrikaziOpremuVM { Proizvodjaci = db.Proizvodjac .Where(x => x.IsDeleted == false).Select(x => new SelectListItem { Text = x.Naziv, Value = x.ProizvodjacId.ToString() }).ToList() }; return(View(Model)); }
public ActionResult UcitajListuOpreme(PrikaziOpremuVM VM) { PrikaziOpremuVM Model = new PrikaziOpremuVM(); IQueryable <Oprema> OpremaQry = db.Oprema.Where(x => x.IsDeleted == false).Where(x => x.OpremaStanje.Where(y => y.Aktivan).Where(y => y.RezervacijaProdajaOprema.Count() == 0).Any()).Where(x => x.Aktivan); if (VM.ProizvodjacId != null) { OpremaQry = OpremaQry.Where(x => VM.ProizvodjacId.Contains(x.ProizvodjacID)); } if (VM.Poredak.HasValue) { switch (VM.Poredak.Value) { case 1: OpremaQry = OpremaQry.OrderBy(x => x.Naziv); break; case 2: OpremaQry = OpremaQry.OrderByDescending(x => x.Naziv); break; case 3: OpremaQry = OpremaQry.OrderByDescending(x => x.Cijena); break; case 4: OpremaQry = OpremaQry.OrderBy(x => x.Cijena); break; } } Model.PagedResult = OpremaQry.Select( x => new PrikaziOpremuVM.Row { OpremaId = x.OpremaId, Naziv = x.Naziv, Cijena = x.Cijena, Slika = x.Slika, Opis = x.Opis, Kolicina = x.OpremaStanje.Where(y => y.Aktivan).Where(y => y.RezervacijaProdajaOprema.Count() == 0).Count(), Aktivan = x.Aktivan, Proizvodjac = x.Proizvodjac } ).GetPaged(VM.Page, 6); if (VM.PrikaziKaoListu) { return(PartialView("UcitajListuOpremeLista", Model)); } return(PartialView(Model)); }
// GET: ModulZaposlenik/Oprema public ActionResult Prikazi(int SalaId) { if (Autentifikacija.KorisnikSesija == null) { return(RedirectToAction("Index", "Login", new { area = "" })); } PrikaziOpremuVM Model = new PrikaziOpremuVM(); Model.SalaId = SalaId; Model.Oprema = ctx.Oprema.Where(x => x.SalaId == SalaId).Select(x => new PrikaziOpremuVM.Podaci { Sala = x.Sala.Naziv, Id = x.Id, Naziv = x.Naziv, Kolicina = x.Kolicina, Opis = x.Opis }).ToList(); return(View("Prikazi", Model)); }
public IActionResult Index(PrikaziOpremuVM VM) { PrikaziOpremuVM Model = new PrikaziOpremuVM { Proizvodjaci = db.Proizvodjac .Where(x => x.IsDeleted == false).ToList(), PopularnaOprema = db.Oprema.Where(x => x.IsDeleted == false).Where(x => x.OcjenaProizvoda.Any()) .Where(x => x.OpremaStanje.Where(y => y.Aktivan).Where(y => y.RezervacijaProdajaOprema.Count() == 0).Any()) .Where(x => x.Aktivan) .OrderByDescending(x => x.OcjenaProizvoda.Average(x => x.Ocjena)) .Take(5) .Select(x => new PreporuceniProizvod { Id = x.OpremaId, Naziv = x.Naziv, Cijena = x.Cijena, Slika = x.Slika, Tip = TipProizvoda.Oprema }).ToList() }; return(View(Model)); }
public ActionResult UcitajListuOpreme(PrikaziOpremuVM VM) { PrikaziOpremuVM Model = new PrikaziOpremuVM { Oprema = db.Oprema.Where(x => x.IsDeleted == false) .Where(x => VM.ProizvodjacId == 0 || VM.ProizvodjacId == x.ProizvodjacID) .Where(x => VM.Aktivan == x.Aktivan) .Where(x => x.Naziv.Contains(VM.Pretraga) || VM.Pretraga == null) .Select( x => new PrikaziOpremuVM.Row { OpremaId = x.OpremaId, Naziv = x.Naziv, Cijena = x.Cijena, Proizvodjac = x.Proizvodjac.Naziv, Slika = x.Slika, Kolicina = x.OpremaStanje.Where(y => y.Aktivan && y.KupacId == null).Count(), Aktivan = x.Aktivan } ).ToList() }; return(PartialView(Model)); }