public ActionResult dohvatiSveProizvode(int?storeid) { if (storeid != null) { //Serialize nece raditi ako se koristi lazy loading using (var newDb = new TrgovinaContext()) { newDb.Configuration.ProxyCreationEnabled = false; var newProducts = newDb.Products.Where(x => x.storeID == storeid).ToList(); return(Json(newProducts, JsonRequestBehavior.AllowGet)); } } else { using (var newDb = new TrgovinaContext()) { newDb.Configuration.ProxyCreationEnabled = false; var newProducts = newDb.Products.ToList(); return(Json(newProducts, JsonRequestBehavior.AllowGet)); } } }