Esempio n. 1
0
        public ActionResult <ItemDto> CreateItem([FromBody] NewItem item)
        {
            Item ret = _stock.Create(new Item()
            {
                Name = item.Name, Types = item.Types
            });

            return(Ok(ret));
        }
Esempio n. 2
0
        public ActionResult Create(StockInfo stockInfo)
        {
            stockInfo.MerchantSysNo = UserAuthHelper.GetCurrentUser().SellerSysNo;
            var success = StockService.Create(stockInfo);

            return(Json(new { Success = success, Msg = success ? LanguageHelper.GetText("操作成功") : LanguageHelper.GetText("操作失败,请稍候再试") }));
        }
        public void TestStock()
        {
            File.Delete(@"stock.csv");
            Stock  stock  = mockItems.StockItem1();
            string result = stockService.Create(stock);

            Assert.AreEqual("New stock item created successfully.", result);
            stock.PortionCount = 5;
            Assert.AreEqual(1, stock.Id);
            bool boolResult = stockService.Edit(stock);

            Assert.AreEqual(true, boolResult);
            List <Stock> stockList = stockService.GetAll();

            Assert.AreEqual(1, stockList.Count);
            Assert.AreEqual(5, stockList[0].PortionCount);
            stockService.Remove(stockList[0].Id);
            stockList = stockService.GetAll();
            Assert.AreEqual(0, stockList.Count);
        }
        public void AddStockItem()
        {
            Stock stock = new Stock();

            Console.WriteLine("Enter stock name");
            stock.Name = Console.ReadLine();
            Console.WriteLine("Enter stock units");
            stock.Unit = Console.ReadLine();
            Console.WriteLine("Enter portion count");
            string  line = Console.ReadLine();
            decimal portionCount;

            if (decimal.TryParse(line, out portionCount))
            {
                stock.PortionCount = Convert.ToDecimal(line);
            }
            else
            {
                while (!decimal.TryParse(line, out portionCount))
                {
                    Console.WriteLine("Invalid number. Try again.");
                    line = Console.ReadLine();
                }
                stock.PortionCount = Convert.ToDecimal(line);
            }
            Console.WriteLine("Enter portion size");
            line = Console.ReadLine();
            decimal portionSize;

            if (decimal.TryParse(line, out portionSize))
            {
                stock.PortionSize = Convert.ToDecimal(line);
            }
            else
            {
                while (!decimal.TryParse(line, out portionSize))
                {
                    Console.WriteLine("Invalid number. Try again.");
                    line = Console.ReadLine();
                }
                stock.PortionSize = Convert.ToDecimal(line);
            }
            Console.WriteLine(stockService.Create(stock));
            EndFunction();
        }