Esempio n. 1
0
    // Inventory Update
    public void inventoryUpdate(int id, int quantity)
    {
        autopartsEntities db = new autopartsEntities();
        productdb         p  = db.productdbs.Find(id);

        p.qty = p.qty - quantity;
        db.SaveChanges();
    }
Esempio n. 2
0
    public void updateInventory(int id, int quantity)
    {
        autopartsEntities db = new autopartsEntities();
        cart c = db.carts.Find(id);

        c.Amount = quantity;
        db.SaveChanges();
    }
Esempio n. 3
0
    // will return all parts added to cart for particular user
    public List <cart> validateProduct(int ClientID)
    {
        string            client = ClientID.ToString();
        autopartsEntities db     = new autopartsEntities();
        List <cart>       orders = (from x in db.carts
                                    where x.ClientId == client &&
                                    x.isInCart
                                    orderby x.DatePurchased
                                    select x).ToList();

        return(orders);
    }
 public void updateName(int id, string partname)
 {
     try
     {
         autopartsEntities db = new autopartsEntities();
         //Fetch
         productdb p = db.productdbs.Find(id);
         p.name = partname;
         db.SaveChanges();
     }
     catch (Exception)
     {
     }
 }
Esempio n. 5
0
 public productdb chooseProduct(int id)
 {
     try
     {
         using (autopartsEntities db = new autopartsEntities())
         {
             productdb product = db.productdbs.Find(id);
             return(product);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 6
0
    public string insertProductType(producttype productType)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            db.producttypes.Add(productType);
            db.SaveChanges();

            return(productType.name + " was successfully inserted");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 7
0
    public string register(user us)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            db.users.Add(us);
            db.SaveChanges();

            return(us.username + " was successfully register.");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 8
0
    public string printOrder(warehouse wh)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();

            db.warehouses.Add(wh);
            db.SaveChanges();

            return("success");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 9
0
//Will change the status of inInCart to false once part is purchased
    public void markOrdersAsPaid(List <cart> carts, string auth)
    {
        autopartsEntities db = new autopartsEntities();

        if (carts != null)
        {
            foreach (cart cart in carts)
            {
                cart oldcart = db.carts.Find(cart.id);
                oldcart.DatePurchased = DateTime.Now;
                oldcart.isInCart      = false;
                oldcart.authID        = auth;
            }
            db.SaveChanges();
        }
    }
Esempio n. 10
0
    public guest getGuestDetail(int id)
    {
        try
        {
            using (autopartsEntities db = new autopartsEntities())
            {
                guest gu = db.guests.Find(id);

                return(gu);
            }
        }
        catch (Exception)
        {
            return(null);
        }
    }
Esempio n. 11
0
 public List <productdb> viewProducts()
 {
     try
     {
         using (autopartsEntities db = new autopartsEntities())
         {
             List <productdb> products = (from x in db.productdbs
                                          select x).ToList();
             return(products);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 12
0
    public string insertCart(cart cart)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            //            AutopartsEntities db = new AutopartsEntities();
            db.carts.Add(cart);
            db.SaveChanges();

            return("Part number : " + cart.ProductId + " was successfully added to cart");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 13
0
    public user getUserDetail(int id)
    {
        try
        {
            using (autopartsEntities db = new autopartsEntities())
            {
                user us = db.users.Find(id);

                return(us);
            }
        }
        catch (Exception)
        {
            return(null);
        }
    }
Esempio n. 14
0
 public List <warehouse> orderList(string auth)
 {
     try
     {
         using (autopartsEntities db = new autopartsEntities())
         {
             List <warehouse> wh = (from x in db.warehouses
                                    where x.paymentID == auth
                                    select x).ToList();
             return(wh);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 15
0
 // Will return total number of quantity
 public int getCost(int ClientID)
 {
     try
     {
         string            client = ClientID.ToString();
         autopartsEntities db     = new autopartsEntities();
         int total = (from x in db.carts
                      where x.ClientId == client &&
                      x.isInCart
                      select x.Amount).Sum();
         return(total);
     }
     catch
     {
         return(0);
     }
 }
Esempio n. 16
0
    public string deleteCart(int id)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            cart p = db.carts.Find(id);

            db.carts.Attach(p);
            db.carts.Remove(p);
            db.SaveChanges();
            return("Part was successfully deleted");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 17
0
    public string deleteProductType(int id)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            producttype       p  = db.producttypes.Find(id);

            db.producttypes.Attach(p);
            db.producttypes.Remove(p);
            db.SaveChanges();
            return(p.name + " was successfully deleted");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 18
0
 public List <cart> cartList(string auth)
 {
     try
     {
         using (autopartsEntities db = new autopartsEntities())
         {
             List <cart> wh = (from x in db.carts
                               where x.authID == auth
                               select x).ToList();
             return(wh);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 19
0
 public List <productdb> viewProductByType(int typeId)
 {
     try
     {
         using (autopartsEntities db = new autopartsEntities())
         {
             List <productdb> products = (from x in db.productdbs
                                          where x.typeId == typeId
                                          select x).ToList();
             return(products);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 20
0
    public string updateGuest(guest g)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            //Fetch
            guest guest = db.guests.Find(1);

            guest.name            = g.name;
            guest.shippingAddress = g.shippingAddress;
            db.SaveChanges();

            return("success");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 21
0
    public string updateProductType(int id, producttype productType)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            //Fetch
            producttype p = db.producttypes.Find(id);
            p.name = productType.name;


            db.SaveChanges();

            return(productType.name + " was successfully updated");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 22
0
    public admin getCost(int id)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            admin             ad = db.admins.Find(id);
            admin             a  = new admin();

            a.shipping = ad.shipping;
            a.handling = ad.handling;
            a.localtax = ad.localtax;

            return(a);
        }
        catch (Exception)
        {
            return(null);
        }
    }
    public string updateParts(int id, productdb product)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            //Fetch
            productdb p = db.productdbs.Find(id);
            p.name   = product.name;
            p.typeId = product.typeId;
            p.qty    = product.qty;
            p.image  = product.image;

            db.SaveChanges();

            return(product.name + " was successfully updated");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 24
0
 public int returnClientID(string username)
 {
     try
     {
         using (autopartsEntities db = new autopartsEntities())
         {
             List <user> us = (from x in db.users
                               where x.username == username
                               select x).ToList();
             foreach (user user in us)
             {
                 return(user.ClientId);
             }
             return(0);
         }
     }
     catch (Exception)
     {
         return(0);
     }
 }
Esempio n. 25
0
    public string setCost(admin a)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            //Fetch
            admin ad = db.admins.Find(a.id);

            ad.shipping = a.shipping;
            ad.handling = a.handling;
            ad.localtax = a.localtax;

            db.SaveChanges();

            return("All the rates were successfully updated");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 26
0
    public string updateCart(int id, cart cart)
    {
        try
        {
            autopartsEntities db = new autopartsEntities();
            //Fetch
            cart p = db.carts.Find(id);
            p.DatePurchased = cart.DatePurchased;
            p.ClientId      = cart.ClientId;
            p.Amount        = cart.Amount;
            p.isInCart      = cart.isInCart;
            p.ProductId     = cart.ProductId;

            db.SaveChanges();

            return("Part number : " + cart.ProductId + " was successfully updated");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
Esempio n. 27
0
 public int login(string username, string password)
 {
     try
     {
         using (autopartsEntities db = new autopartsEntities())
         {
             List <user> us = (from x in db.users
                               where x.username == username
                               select x).ToList();
             foreach (user user in us)
             {
                 if (user.password == password)
                 {
                     return(1);
                 }
             }
             return(0);
         }
     }
     catch (Exception)
     {
         return(0);
     }
 }