public void ProductServiceContext_NotNull() { //Act var result = new ProductServiceContext(); //Assert Assert.IsNotNull(result); }
public List <Product> GetAllProducts() { using (ProductServiceContext ctx = new ProductServiceContext()) { products = ctx.Product.ToList(); }; return(products); }
public void ProductServiceContext_HasNotNullProducts() { //Arrange var context = new ProductServiceContext(); //Act var result = context.Products; //Assert Assert.IsNotNull(result); }
public Product GetById(int id) { Product product; using (ProductServiceContext ctx = new ProductServiceContext()) { product = ctx.Product.FirstOrDefault(x => x.Id == id); }; return(product); }
public ProductVM GetProductVM(int id) { ProductVM productVM = new ProductVM(); using (ProductServiceContext ctx = new ProductServiceContext()) { productVM.product = ctx.Product.FirstOrDefault(x => x.Id == id); productVM.productInformation = ctx.ProductInformation.FirstOrDefault(x => x.Keyboard_Id == id); }; return(productVM); }
public ProductInformation GetInfoById(int id) { ProductInformation productInfo; using (ProductServiceContext ctx = new ProductServiceContext()) { var products = ctx.ProductInformation.ToList(); productInfo = ctx.ProductInformation.FirstOrDefault(x => x.Keyboard_Id == id); }; return(new ProductInformation()); }
private void GetCategories(ProductServiceContext context) { context.Categories.AddOrUpdate(x => x.Id, new Category() { Id = 1, Name = "Cocktails" }, new Category() { Id = 2, Name = "Beers" }, new Category() { Id = 3, Name = "Wines" }, new Category() { Id = 4, Name = "Spirits" } ); }
private void GetProducts(ProductServiceContext context) { //TODO: Replace file path with the directory you are running the code from. string jsonFilePath = @"C:\Users\fiona.mccartney\Source\Repos\ProductService\ProductService\App_Data\products.json"; string productJsonAll = GetEmbeddedResourceAsString(jsonFilePath); JArray jsonValProducts = JArray.Parse(productJsonAll) as JArray; dynamic productsData = jsonValProducts; foreach (dynamic product in productsData) { context.Products.AddOrUpdate(x => x.Id, new Product { Id = product.id, Name = product.name, Description = product.description, CategoryId = product.categoryId } ); } }
public ProductsController(ProductServiceContext repository) { _repository = repository; }
public ProductsController() { _repository = new ProductServiceContext(); }
public CategoriesController(ProductServiceContext repository) { _repository = repository; }
public CategoriesController() { _repository = new ProductServiceContext(); }