//[HttpPost] //public ActionResult Index(ProductViewModel model) //{ // // check model.SelectedItemId here // return View(); //} public string AjaxAnswerTest(string ModelType) { string[] test = Request.Params.GetValues("ddlFurnitureTypeList"); string value = test[0]; Entities gadb = new Entities(); int numOfRows = gadb.tProduct.Where(x => x.CategoryID == int.Parse(value)).Count(); string result = "Du skickade " + value + "." + Environment.NewLine + "Det finns " + numOfRows + " st produkter i denna kategori."; return result; }
public JsonResult AjaxAnswerJson() { string[] test = Request.Params.GetValues("ddlFurnitureTypeList"); string value = test[0]; using (Entities gadb = new Entities()) { var jss = (from x in gadb.tProduct where SqlFunctions.StringConvert((double)x.CategoryID) == value select new SelectListItem { Text = x.GardenArtArticleNumber, Value = SqlFunctions.StringConvert((double)x.ProductID) }); return Json(jss.ToList(), JsonRequestBehavior.AllowGet); } }
public OrderModels() { if (this.DropDownList == null) { Entities gadb = new Entities(); var items = (IEnumerable<SelectListItem>)gadb.tCategory .GroupBy(x => x.Name) .Select(g => g.FirstOrDefault()) .Select(x => new SelectListItem() { Value = SqlFunctions.StringConvert((double)x.CategoryID), Text = x.Name }); this.DropDownList = new SelectList ( items, "Value", "Text" ); } }
public JsonResult AjaxProductBuilderJson() { string[] test = Request.Params.GetValues("ddlFurnitureModelList"); int value = Convert.ToInt32(test[0].Trim()); using (Entities gadb = new Entities()) { var jss = (from p in gadb.tProduct join pp in gadb.tProductPicture on p.ProductID equals pp.ProductID into join1 from j1 in join1.DefaultIfEmpty() join pic in gadb.tPicture on j1.PictureID equals pic.PictureID into join2 from j2 in join2.DefaultIfEmpty() where p.ProductID == value select new { ProductID = p.ProductID, ItemNumber = p.GardenArtArticleNumber, Price = p.SellingPriceWarehouseSEK, FullContainer = p.ItemsPerContainer, Description = p.Description, Picture = "../Images/" + (j2.Picture == null ? "noimage.gif" : j2.Picture) }); // select p.*, ISNULL(pic.Picture, '') Picture from tProduct p // left outer join tProductPicture pp on pp.ProductID = p.ProductID // left outer join tPicture pic on pic.PictureID = pp.PictureID //where p.ProductID = 1 //var jss = (from x in gadb.t_ga_product // where x.ProductID == value // select new // { // ProductID = x.ProductID, // ItemNumber = x.ItemNumber, // Price = x.FobGuangzhouUSD, // FullContainer = x.Quantity40GP, // Description = x.Description, // Picture = "../Images/Products/" + x.Picture // }); return Json(jss.ToList(), JsonRequestBehavior.AllowGet); } }
public MaterialViewModel() { _db = new Entities(); }
public CategoryViewModel() { _db = new Entities(); }