//[OutputCache(Duration = 3600, VaryByParam = "code,v")] public ActionResult GetPrice(int?code, string v) { Tax_Rate t = new Tax_Rate { id = 1, rate = 10, type = 2 }; //var product = ProductsList.FirstOrDefault(x => x.Id == code); var allPosItems = _posItemService.GetAllInclude("StockItem").ToList(); var availableItemsId = allPosItems.Where(x => x.Remaining > 0 && x.DistributionPointId == DistributionPointId).Select(x => x.ItemId).ToList(); var product = ProductsList.FirstOrDefault(x => x.Id == code && availableItemsId.Contains((int)x.Id)); if (product == null) { product = new POSService.Entities.StockItem(); product.TotalQuantity = 0; } else { var posItem = allPosItems.FirstOrDefault(x => x.ItemId == code.Value); product.TotalQuantity = posItem.Remaining; } return(Json(new { price = decimal.Zero, name = product.StockItemName, code = product.Id.ToString(), tax_rate = t, available = product.TotalQuantity }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetProductCount(int?product_id) { var allPosItems = _posItemService.GetAllInclude("StockItem").ToList(); var availableItemsId = allPosItems.Where(x => x.Remaining > 0 && x.DistributionPointId == DistributionPointId).Select(x => x.ItemId).ToList(); var product = ProductsList.FirstOrDefault(x => x.Id == product_id && availableItemsId.Contains((int)x.Id)); if (product == null) { product = new POSService.Entities.StockItem(); product.TotalQuantity = 0; } else { var posItem = allPosItems.FirstOrDefault(x => x.ItemId == product_id.Value); product = new POSService.Entities.StockItem(); product.TotalQuantity = posItem.Remaining; } return(Json(new { Remainder = product.TotalQuantity }, JsonRequestBehavior.AllowGet)); }