Пример #1
0
        public JsonResult GetCommodityImport(int?locationID, int?customerID, int?warehouseID, int?priceCategoryID, int?applyToSalesVersusReturns, int?promotionID, DateTime?entryDate, string searchText)
        {
            try
            {
                var commodityResult = new { CommodityID = 0, CommodityCode = "", CommodityName = "", CommodityTypeID = 0, WarehouseID = 0, WarehouseCode = "", QuantityAvailable = new decimal(0), ControlFreeQuantity = new decimal(0), ListedPrice = new decimal(0), GrossPrice = new decimal(0), DiscountPercent = new decimal(0), TradeDiscountRate = new decimal(0), VATPercent = new decimal(0) };

                var result = commodityRepository.GetCommodityAvailables(locationID, customerID, warehouseID, priceCategoryID, applyToSalesVersusReturns, promotionID, entryDate, searchText).Select(s => new { s.CommodityID, s.CommodityCode, s.CommodityName, s.CommodityTypeID, s.WarehouseID, s.WarehouseCode, s.QuantityAvailable, s.ControlFreeQuantity, s.ListedPrice, s.GrossPrice, s.DiscountPercent, s.TradeDiscountRate, s.VATPercent, s.Bookable });
                if (result.Count() > 0 && (bool)result.First().Bookable)
                {
                    commodityResult = new { CommodityID = result.First().CommodityID, CommodityCode = result.First().CommodityCode, CommodityName = result.First().CommodityName, CommodityTypeID = result.First().CommodityTypeID, WarehouseID = result.First().WarehouseID, WarehouseCode = result.First().WarehouseCode, QuantityAvailable = (decimal)result.First().QuantityAvailable, ControlFreeQuantity = (decimal)result.First().ControlFreeQuantity, ListedPrice = (decimal)result.First().ListedPrice, GrossPrice = (decimal)result.First().GrossPrice, DiscountPercent = (decimal)result.First().DiscountPercent, TradeDiscountRate = (decimal)result.First().TradeDiscountRate, VATPercent = (decimal)result.First().VATPercent }
                }
                ;

                return(Json(commodityResult, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { CommodityID = 0, CommodityCode = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }