public List <Products> getAllProducts() { using (var context = new CustomerProductDbContext()) { var result = context.Products.Select(x => x).ToList(); return(result); } }
public void addProduct(Products product) { using (var context = new CustomerProductDbContext()) { context.Products.Add(product); context.SaveChanges(); } }
public void updateCustomer(VCustomerUpdate updateCustomer) { using (var context = new CustomerProductDbContext()) { context.VCustomerUpdate.Update(updateCustomer); context.SaveChanges(); } }
public IActionResult Get() { using (var context = new CustomerProductDbContext()) { var r = d.getAllProducts(); return(Ok(r)); } }
public IActionResult Get(Products pro) { using (var context = new CustomerProductDbContext()) { d.searchProduct(pro); return(Ok(pro)); } }
public void filterProduct(Products product) { using (var context = new CustomerProductDbContext()) { var s = context.Database.ExecuteSqlCommand("spFilterProduct @searchtext", new SqlParameter("@searchtext", product.ProductStatus) ); } }
public void addCustomer(Customers customer) { using (var context = new CustomerProductDbContext()) { Random r = new Random(); customer.CustomerNumber = r.Next(1000); context.Customers.Add(customer); context.SaveChanges(); } }
public void deleteProduct(int id) { var product = new Products { ProductId = id }; using (var context = new CustomerProductDbContext()) { context.Remove <Products>(product); context.SaveChanges(); } }
public void deleteCustomer(int id) { var customer = new Customers { CustomerNumber = id }; using (var context = new CustomerProductDbContext()) { context.Remove <Customers>(customer); context.SaveChanges(); } }
public IActionResult Get(Customers customer) { using (var context = new CustomerProductDbContext()) { int i = d.loginCustomer(customer); if (i == 0) { return(Ok("Login Failed")); } else { return(Ok(customer.CustomerNumber)); } } }
public int loginCustomer(Customers customer) { using (var context = new CustomerProductDbContext()) { var result = context.Customers.Single(cust => cust.Email == customer.Email && cust.Password == customer.Password); if (result != null) { int i = result.CustomerNumber; return(i); } else { return(0); } } }