public Product Add(Product item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            item.Id = _nextId++;
            products.Add(item);

            return item;
        }
        public bool Update(Product item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            int index = products.FindIndex(p => p.Id == item.Id);
            if (index == -1)
            {
                return false;
            }

            products.RemoveAt(index);
            products.Add(item);

            return true;
        }
Beispiel #3
0
 static void AddProduct(Product value)
 {
     client.SendPostOrPutRequest<Product, Product>(value, "products", "POST");
 }
Beispiel #4
0
 static void UpdateProduct(Product value)
 {
     client.SendPostOrPutRequest<string, Product>(value, string.Format("products/{0}", value.Id), "PUT");
 }
Beispiel #5
0
 static void RemoveProduct(Product value)
 {
     client.SendPostOrPutRequest<string, Product>(value, string.Format("products/{0}", value.Id), "DELETE");
 }