Exemplo n.º 1
0
 public List <customer> GetAllCustomers()
 {
     try
     {
         using (etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities())
         {
             List <customer> customers = (from x in db.customers select x).ToList();
             return(customers);
         }
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 public customer GetCustomer(string id)
 {
     try
     {
         using (etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities())
         {
             customer customers = db.customers.Find(id);
             return(customers);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 3
0
        public String InsertCustomer(customer customer)
        {
            try
            {
                etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities();
                db.customers.Add(customer);
                db.SaveChanges();
                return(customer.customer_email + " was successfully added");
            }

            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Exemplo n.º 4
0
        public String InsertProduct(product product)
        {
            try
            {
                etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities();
                db.products.Add(product);
                db.SaveChanges();
                return(product.product_name + " was successfully added");
            }

            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Exemplo n.º 5
0
 public List <product> GetAllProducts()
 {
     try
     {
         using (etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities())
         {
             List <product> products = (from x in db.products select x).ToList();
             return(products);
         }
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Exemplo n.º 6
0
 public product GetProduct(int id)
 {
     try
     {
         using (etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities())
         {
             product products = db.products.Find(id);
             return(products);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 7
0
        public String DeleteCustomer(int id)
        {
            try
            {
                etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities();
                customer p = db.customers.Find(id);
                db.customers.Attach(p);
                db.customers.Remove(p);
                db.SaveChanges();
                return(p.customer_address + " was successfully deleted");
            }

            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Exemplo n.º 8
0
        public String DeleteProduct(int id)
        {
            try
            {
                etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities();
                product p = db.products.Find(id);
                db.products.Attach(p);
                db.products.Remove(p);
                db.SaveChanges();
                return(p.product_name + " was successfully deleted");
            }

            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Exemplo n.º 9
0
        public String UpdateCustomer(string id, customer customer)
        {
            try
            {
                etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities();
                customer c = db.customers.Find(id);

                c.customer_address = customer.customer_address;
                c.first_name       = customer.first_name;
                c.last_name        = customer.last_name;



                db.SaveChanges();
                return(c.customer_email + " was successfully updated");
            }

            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Exemplo n.º 10
0
        public String UpdateProduct(int id, product product)
        {
            try
            {
                etvffqgz_megastoreEntities db = new etvffqgz_megastoreEntities();
                product p = db.products.Find(id);
                p.product_description = product.product_description;
                p.product_name        = product.product_name;
                p.product_type        = product.product_type;
                p.image_url           = product.image_url;
                p.stock                       = product.stock;
                p.price_per_unit              = product.price_per_unit;
                p.categories_catogories_id    = product.categories_catogories_id;
                p.product_type_idproduct_type = product.product_type_idproduct_type;

                db.SaveChanges();
                return(product.product_name + " was successfully updated");
            }

            catch (Exception e)
            {
                return("Error:" + e);
            }
        }