示例#1
0
文件: Program.cs 项目: rnmisrahi/JB
        static void Main(string[] args)
        {
            NewClient.InventoryService.InventoryClient service = new InventoryClient();

            Console.WriteLine(service.GetMessage());
            Console.WriteLine("Enter name:");
            var name = Console.ReadLine();
            Item[] items;
            while (name != "quit")
            {
                try
                {
                    string s = service.GetMessage();
                    Console.WriteLine(string.Format("message: {0}", s));
                    int n = service.AddItem(name, 5);
                    items = service.GetItems();
                    foreach (Item item in items)
                    {
                        Console.WriteLine("Item: {0}. Qty: {1}", item.Name, item.Quantity);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                Console.WriteLine("Enter name:");
                name = Console.ReadLine();
            }
        }
示例#2
0
        public async void AddItem(string ean)
        {
            var item = await _inventoryClient.AddItem(_someFancyUniqueId, ean);

            var currentItem = Items.SingleOrDefault(x => x.Ean == item.Ean);

            if (currentItem == null)
            {
                Items.Add(new InventoryItem {
                    Ean = item.Ean, Quantity = item.Quantity, Text = item.Text
                });
            }
            else
            {
                currentItem.Quantity = item.Quantity;
            }
        }
示例#3
0
 public ActionResult Create(Item item)
 {
     InventoryClient client = new InventoryClient();
     client.AddItem(item.ItemName, item.Quantity);
     return RedirectToAction("Index");
 }