Ejemplo n.º 1
0
    public void updateInventory(int id, int quantity)
    {
        autopartsEntities db = new autopartsEntities();
        cart c = db.carts.Find(id);

        c.Amount = quantity;
        db.SaveChanges();
    }
Ejemplo n.º 2
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();
    }
 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)
     {
     }
 }
Ejemplo n.º 4
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);
        }
    }
Ejemplo n.º 5
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);
        }
    }
Ejemplo n.º 6
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);
        }
    }
Ejemplo n.º 7
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();
        }
    }
Ejemplo 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);
        }
    }
Ejemplo n.º 9
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);
        }
    }
Ejemplo n.º 10
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);
        }
    }
Ejemplo n.º 11
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);
        }
    }
Ejemplo n.º 12
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);
        }
    }
Ejemplo n.º 13
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);
        }
    }
    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);
        }
    }
Ejemplo n.º 15
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);
        }
    }