public IActionResult Pretraga(string srchTxt) { if (srchTxt == null) { return(RedirectToAction(nameof(Index))); } srchTxt = srchTxt.ToLower(); KupacIndexVM model = new KupacIndexVM(); model.Kupci = db.Kupci.Include(x => x.Grad).Where(y => y.NazivKupca.ToLower().Contains(srchTxt)).Select(y => new KupacIndexVM.Row() { KupacID = y.KupacID, NazivKupca = y.NazivKupca, ID_broj = y.ID_broj, PDV_broj = y.PDV_broj, Adresa = y.Adresa, Grad = y.Grad.Naziv, Kredit = y.Kredit, //Dugovanje = db.Racuni.Where(t => t.KupacID == y.KupacID).Sum(p => p.UkupnoZaNaplatu) - db.Uplate.Where(r => r.KupacID == y.KupacID).Sum(e => e.Iznos) }).ToList(); model.srchTxt = srchTxt; return(View("Index", model)); }
public async Task <IViewComponentResult> InvokeAsync(string pretraga = null, int sortirajPo = 1, int zanr = 0, int kategorija = 0, int from = 0, int to = 20) { KupacIndexVM kupacIndexVM = await GetItemsAsync(pretraga, sortirajPo, zanr, kategorija, from, to, db); ViewBag.VM = kupacIndexVM; return(View()); }
public KupacIndexVM GetKupacIndexVM(string pretraga = null, int sortirajPo = 1, int zanr = 0, int kategorija = 0, int from = 0, int to = 20, eContext db = null) { KupacIndexVM kupacIndexVM = new KupacIndexVM() { pretraga = pretraga, sortirajPo = sortirajPo, zanr = zanr, kategorija = kategorija, from = from, to = to }; PretragaIgra p = new PretragaIgra(); //pretrazivanje List <Igra> igre = p.PretragaIgrica(kupacIndexVM.pretraga, db); //filtiranje igre = p.PretragaZanrKategorija(igre, kupacIndexVM.zanr, kupacIndexVM.kategorija, db); //sortiranje igre = p.Sortiranje(igre, kupacIndexVM.sortirajPo, db); //to -= from; to = 20; if (from + to < igre.Count) { igre = igre.GetRange(from, to); } else { to = igre.Count() - from; if (to > 0) { igre = igre.GetRange(from, to); } else { igre = new List <Igra>(); } } kupacIndexVM.Igre = igre; foreach (Igra x in igre) { kupacIndexVM.PopustProcent.Add(p.IgraAktivanPopust(x.IgraID, db)); kupacIndexVM.novaCijena.Add(p.cijenaSaPopustom(x.IgraID, db)); } return(kupacIndexVM); }
public IActionResult Index() { KupacIndexVM model = new KupacIndexVM(); model.Kupci = db.Kupci.Include(x => x.Grad).Where(p => p.NazivKupca != "---").Select(y => new KupacIndexVM.Row() { KupacID = y.KupacID, NazivKupca = y.NazivKupca, ID_broj = y.ID_broj, PDV_broj = y.PDV_broj, Adresa = y.Adresa, Grad = y.Grad.Naziv, Kredit = y.Kredit, //Dugovanje = (db.Racuni.Where(t => t.KupacID == y.KupacID && t.Placeno==false).Sum(p => p.UkupnoZaNaplatu)) - (db.Racuni.Where(t => t.KupacID == y.KupacID && t.Placeno == false).Sum(p => p.DosadPlaceno)) - (db.Uplate.Where(r => r.KupacID == y.KupacID).Sum(e => e.Iznos)) }).ToList(); return(View(model)); }
public IActionResult Index(string pretraga = null, int sortirajPo = 1, int zanr = 0, int kategorija = 0, int from = 0, int to = 20) { #region DodjelVrijednosti KupacIndexVM kupacIndexVM = new KupacIndexVM() { pretraga = pretraga, sortirajPo = sortirajPo, zanr = zanr, kategorija = kategorija, from = from, to = to, gameGenre = db.GameGenre.ToList(), ratingCategorie = db.RatingCategorie.ToList() }; #endregion #region PovratneVrijednosti ViewBag.kupacIndexVM = kupacIndexVM; return(View("Index")); #endregion }