Example #1
0
 public List <Products> getAllProducts()
 {
     using (var context = new CustomerProductDbContext())
     {
         var result = context.Products.Select(x => x).ToList();
         return(result);
     }
 }
Example #2
0
 public void addProduct(Products product)
 {
     using (var context = new CustomerProductDbContext())
     {
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
Example #3
0
 public void updateCustomer(VCustomerUpdate updateCustomer)
 {
     using (var context = new CustomerProductDbContext())
     {
         context.VCustomerUpdate.Update(updateCustomer);
         context.SaveChanges();
     }
 }
Example #4
0
 public IActionResult Get()
 {
     using (var context = new CustomerProductDbContext())
     {
         var r = d.getAllProducts();
         return(Ok(r));
     }
 }
Example #5
0
 public IActionResult Get(Products pro)
 {
     using (var context = new CustomerProductDbContext())
     {
         d.searchProduct(pro);
         return(Ok(pro));
     }
 }
Example #6
0
        public void filterProduct(Products product)
        {
            using (var context = new CustomerProductDbContext())
            {
                var s = context.Database.ExecuteSqlCommand("spFilterProduct @searchtext",
                                                           new SqlParameter("@searchtext", product.ProductStatus)


                                                           );
            }
        }
Example #7
0
        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();
            }
        }
Example #8
0
        public void deleteProduct(int id)
        {
            var product = new Products
            {
                ProductId = id
            };

            using (var context = new CustomerProductDbContext())
            {
                context.Remove <Products>(product);
                context.SaveChanges();
            }
        }
Example #9
0
        public void deleteCustomer(int id)
        {
            var customer = new Customers
            {
                CustomerNumber = id
            };

            using (var context = new CustomerProductDbContext())
            {
                context.Remove <Customers>(customer);
                context.SaveChanges();
            }
        }
Example #10
0
 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));
         }
     }
 }
Example #11
0
        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);
                }
            }
        }