public void AddArchiveRecordToDb(EntityProducts.Product product) { _dbContext.Products.Update(product) .Entity .IsArchived = true; _dbContext.SaveChanges(); }
// in goes an entity model and out comes a service model public static ServiceProducts.Product SerialiseProduct(EntityProducts.Product entityProduct) { var serviceProduct = new ServiceProducts.Product() { Id = entityProduct.Id, Name = entityProduct.Name, Description = entityProduct.Description, Category = entityProduct.Category, Price = entityProduct.Price, IsOnSale = entityProduct.IsOnSale, IsArchived = entityProduct.IsArchived, IsTaxable = entityProduct.IsTaxable, CreatedOn = entityProduct.CreatedOn, UpdatedOn = entityProduct.UpdatedOn }; return(serviceProduct); }
public void DeleteProductFromDb(EntityProducts.Product productToDelete) { _dbContext.Products.Remove(productToDelete); _dbContext.SaveChanges(); }
public void AddProductToDb(EntityProducts.Product productToAdd) { _dbContext.Products.Add(productToAdd); _dbContext.SaveChanges(); }