Exemplo n.º 1
0
        public IEnumerable <ItemViewModel> FindAllItems()
        {
            Console.WriteLine("Find All Items API");
            //List<Item> list = itemService.FindAllItems();
            List <Item>          list  = itemService.FindAllActiveItems();
            List <ItemViewModel> items = new List <ItemViewModel>();

            foreach (Item i in list)
            {
                items.Add(new ItemViewModel
                {
                    ItemCode         = i.ItemCode,
                    ItemCategoryName = i.ItemCategory != null ? i.ItemCategory.Name : "",
                    Description      = i.Description,
                    ReorderLevel     = i.ReorderLevel,
                    ReorderQuantity  = i.ReorderQuantity,
                    Uom       = i.Uom,
                    Quantity  = i.Inventory.Quantity,
                    UnitPrice = itemPriceService.GetDefaultPrice(i, 1),

                    ImagePath = (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("/Images/" + i.ItemCode.ToString() + ".JPG"))) ? i.ItemCode : "default"
                });
            }
            return(items);
        }
Exemplo n.º 2
0
        public IEnumerable <StockAdjustmentDetailViewModel> GetStockAdjustmentDetail(string StockAdjustmentId)
        {
            stockAdjustmentService = new StockAdjustmentService(Context);
            itemPriceService       = new ItemPriceService(Context);
            itemService            = new ItemService(Context);

            List <StockAdjustmentDetailViewModel> detailListViewModel = new List <StockAdjustmentDetailViewModel>();
            StockAdjustment sd = stockAdjustmentService.FindStockAdjustmentById(StockAdjustmentId);
            List <StockAdjustmentDetail> detaillist = sd.StockAdjustmentDetails;

            foreach (StockAdjustmentDetail sad in detaillist)
            {
                StockAdjustmentDetailViewModel sadv = new StockAdjustmentDetailViewModel();
                string itemcode = sad.ItemCode;
                sadv.ItemCode = itemcode;
                Item item = itemService.FindItemByItemCode(itemcode);
                sadv.Description = item.Description == null ? "" : item.Description;
                sadv.Reason      = sad.Reason == null ? "" : sad.Reason;

                sadv.UnitPrice = itemPriceService.GetDefaultPrice(item, 1);
                if (sadv.UnitPrice.CompareTo("250") == -1)
                {
                    sadv.PriceColor = "-1";
                }
                else
                {
                    sadv.PriceColor = "1";
                }

                sadv.Adjustment = sad.AfterQuantity - sad.OriginalQuantity;
                detailListViewModel.Add(sadv);
            }
            ;


            return(detailListViewModel);
        }