public void AddRestaurantProduct(int id, Product prod) { var restProduct = new RestaurantProduct { Quantity = 1, ProductId = prod.Id, RestaurantId = id }; var restProd = _repo.GetRestaurantProductById(prod.Id); if (restProd != null) { restProd.Quantity++; } else { _repo.AddRestaurantProducts(restProduct); } _repo.SaveChanges(); }