Exemplo n.º 1
0
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            ElectronicaEntities db = new ElectronicaEntities();

            //Fetch objects from the database

            Cart n = db.Carts.Find(id);

            n.DatePurchased = cart.DatePurchased;
            n.ClientID      = cart.ClientID;
            n.Amount        = cart.Amount;
            n.IsInCart      = cart.IsInCart;
            n.ProductID     = cart.ProductID;


            db.SaveChanges();
            return(cart.DatePurchased + "was successfully updated");
        }

        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Exemplo n.º 2
0
    public void ToInsertUserSpecifics(UserSpecific info)
    {
        ElectronicaEntities db = new ElectronicaEntities();

        db.UserSpecifics.Add(info);
        db.SaveChanges();
    }
Exemplo n.º 3
0
    public void UpdateCartQuantity(int id, int quantity)
    {
        ElectronicaEntities db = new ElectronicaEntities();
        Cart n = db.Carts.Find(id);

        n.Amount = quantity;

        db.SaveChanges();
    }
Exemplo n.º 4
0
    public void RecordOrdersAsPaidfor(List <Cart> carts)
    {
        ElectronicaEntities db = new ElectronicaEntities();

        if (carts != null)
        {
            foreach (Cart cart in carts)
            {
                Cart exCart = db.Carts.Find(cart.ID);
                exCart.DatePurchased = DateTime.Now;
                exCart.IsInCart      = false;
            }
            db.SaveChanges();
        }
    }
Exemplo n.º 5
0
    public string InsertProductType(ProductType productType)
    {
        try
        {
            ElectronicaEntities db = new ElectronicaEntities();
            db.ProductTypes.Add(productType);
            db.SaveChanges();

            return(productType.Name + "was successfully inserted into the database");
        }

        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Exemplo n.º 6
0
    public string InsertCart(Cart cart)
    {
        try
        {
            ElectronicaEntities db = new ElectronicaEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return("was successfully added to the cart");
        }

        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Exemplo n.º 7
0
    public string DeleteProductType(int id)
    {
        try
        {
            ElectronicaEntities db          = new ElectronicaEntities();
            ProductType         productType = db.ProductTypes.Find(id);

            db.ProductTypes.Attach(productType);
            db.ProductTypes.Remove(productType);
            db.SaveChanges();

            return(productType.Name + "was successfully deleted");
        }

        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Exemplo n.º 8
0
    public string DeleteCart(int id)
    {
        try
        {
            ElectronicaEntities db = new ElectronicaEntities();
            Cart cart = db.Carts.Find(id);

            db.Carts.Attach(cart);
            db.Carts.Remove(cart);
            db.SaveChanges();

            return(cart.DatePurchased + "was successfully deleted");
        }

        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Exemplo n.º 9
0
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            ElectronicaEntities db = new ElectronicaEntities();

            //Fetch objects from the database

            ProductType n = db.ProductTypes.Find(id);
            n.Name = productType.Name;


            db.SaveChanges();
            return(productType.Name + "was successfully updated");
        }

        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Exemplo n.º 10
0
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            ElectronicaEntities db = new ElectronicaEntities();

            //Fetch objects from the database

            Product n = db.Products.Find(id);
            n.Name        = product.Name;
            n.Price       = product.Price;
            n.TypeId      = product.TypeId;
            n.Description = product.Description;
            n.Image       = product.Image;

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

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