public void EditProducts(Product product) { var original = this.FindProducts(product.Id); original.productName = product.productName; original.productID = product.productID; original.material = product.material; original.description = product.description; original.price = product.price; original.imageUrl = product.imageUrl; _repo.SaveChanges(); }
public HttpResponseMessage Post(Product product) { if (ModelState.IsValid) { if (product.Id == 0) { _productservice.Create(product); return Request.CreateResponse(HttpStatusCode.OK, product); } else { _productservice.EditProducts(product); return Request.CreateResponse(HttpStatusCode.OK, product); } } return Request.CreateResponse(HttpStatusCode.BadRequest, this.ModelState); }
public void Create(Product product) { _repo.Add<Product>(product); _repo.SaveChanges(); }