internal void UpdateCarProduct(int productID, string name, decimal price, int quantity, int year, string color, int supplierID) { CarProduct productToUpdate = CarProducts.FirstOrDefault(p => p.ProductID == productID); if (productToUpdate != null) { productToUpdate.Name = name; productToUpdate.Price = price; productToUpdate.Quantity = quantity; productToUpdate.Year = year; productToUpdate.Color = color; productToUpdate.SupplierID = supplierID; } }
public void AddCarProduct(string name, decimal price, int quantity, int year, string color, int supplierID) { CarProduct newProduct = new CarProduct { Name = name, Price = price, Quantity = quantity, Year = year, Color = color, SupplierID = supplierID }; CarProducts.Add(newProduct); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } CarProducts = await _context.CarProducts .Include(c => c.CarModel) .Include(c => c.Factory).FirstOrDefaultAsync(m => m.Id == id); if (CarProducts == null) { return(NotFound()); } return(Page()); }