public void CreateProduct(DTOs.Product product) { usersWebService.Product prod = new usersWebService.Product(); prod.ID = (int)product.Id; prod.Ean = product.Ean; prod.CategoryId = product.CategoryId; prod.CategoryName = product.CategoryName; prod.BrandId = product.BrandId; prod.BrandName = product.BrandName; prod.Name = product.Name; prod.Description = product.Description; prod.Price = product.Price; prod.ExpectedRestock = product.ExpectedRestock; prod.InStock = product.InStock; prod.Supplier = product.Supplier; context.Product.Add(prod); }
public void UpdateProduct(DTOs.Product product, int Id) { DTOs.Product prods = GetById(Id); usersWebService.Product prod = new usersWebService.Product(); prod.ID = (int)prods.Id; context.Product.Remove(prod); prod.ID = (int)product.Id; prod.Ean = product.Ean; prod.CategoryId = product.CategoryId; prod.CategoryName = product.CategoryName; prod.BrandId = product.BrandId; prod.BrandName = product.BrandName; prod.Name = product.Name; prod.Description = product.Description; prod.Price = product.Price; prod.ExpectedRestock = product.ExpectedRestock; prod.InStock = product.InStock; prod.Supplier = product.Supplier; context.Product.Add(prod); //context.Entry(product).State = EntityState.Modified; Save(); }