public IEnumerable PutProduct(int id, Product product) { product.Id = id; if (Repository.Update(product)) { return Repository.GetAll(); } return null; }
public Product Add(Product item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } // TO DO : Code to save record into database item.Id = _nextId++; _products.Add(item); return item; }
public bool Update(Product item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } // TO DO : Code to update record into database var index = _products.FindIndex(p => p.Id == item.Id); if (index == -1) { return false; } _products.RemoveAt(index); _products.Insert(index, item); return true; }
public Product PostProduct(Product item) { return Repository.Add(item); }