public static void Delete(ClientProductViewModel product) { ClientProductViewModel target = One(p => p.ProductID == product.ProductID); if (target != null) { All().Remove(target); } }
public static void Update(ClientProductViewModel product) { ClientProductViewModel target = One(p => p.ProductID == product.ProductID); if (target != null) { target.ProductName = product.ProductName; target.UnitPrice = product.UnitPrice; target.UnitsInStock = product.UnitsInStock; target.Discontinued = product.Discontinued; target.Category = product.Category; target.CategoryID = product.Category.CategoryID; } }
public static void Insert(ClientProductViewModel product) { product.ProductID = All().OrderByDescending(p => p.ProductID).First().ProductID + 1; product.CategoryID = product.Category.CategoryID; All().Insert(0, product); }