Beispiel #1
0
        public void InsertUserDetail(UserInformation userDetail)
        {
            GarageDBEntities6 db = new GarageDBEntities6();

            db.UserInformations.Add(userDetail);
            db.SaveChanges();
        }
Beispiel #2
0
    public void UpdateQuantity(int id, int quantity)
    {
        GarageDBEntities6 db = new GarageDBEntities6();
        Cart cart            = db.Carts.Find(id);

        cart.Amount = quantity;

        db.SaveChanges();
    }
 public string InsertProductType(ProductType productType)
 {
     try
     {
         GarageDBEntities6 db = new GarageDBEntities6();
         db.ProductTypes.Add(productType);
         db.SaveChanges();
         return(productType.Name + "was succesfully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e);
     }
 }
Beispiel #4
0
 public string InsertCart(Cart cart)
 {
     try
     {
         GarageDBEntities6 db = new GarageDBEntities6();
         db.Carts.Add(cart);
         db.SaveChanges();
         return(cart.DatePurchased + "was succesfully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e);
     }
 }
Beispiel #5
0
    public void MarkOrderAsPaid(List <Cart> carts)
    {
        GarageDBEntities6 db = new GarageDBEntities6();

        if (carts != null)
        {
            foreach (Cart cart in carts)
            {
                Cart oldCart = db.Carts.Find(cart.ID);
                oldCart.DatePurchased = DateTime.Now;
                oldCart.IsInCart      = false;
            }

            db.SaveChanges();
        }
    }
    public string DeleteProductType(int id)
    {
        try
        {
            GarageDBEntities6 db          = new GarageDBEntities6();
            ProductType       productType = db.ProductTypes.Find(id);

            db.ProductTypes.Attach(productType);
            db.ProductTypes.Remove(productType);
            db.SaveChanges();
            return(productType.Name + "was succesfully deleted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageDBEntities6 db = new GarageDBEntities6();
            ProductType       p  = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + "was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Beispiel #8
0
    public string DeleteCart(int id)
    {
        try
        {
            GarageDBEntities6 db = new GarageDBEntities6();
            Cart cart            = db.Carts.Find(id);

            db.Carts.Attach(cart);
            db.Carts.Remove(cart);
            db.SaveChanges();
            return(cart.DatePurchased + "was succesfully deleted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Beispiel #9
0
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            GarageDBEntities6 db = new GarageDBEntities6();
            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(cart.DatePurchased + "was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Beispiel #10
0
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            GarageDBEntities6 db = new GarageDBEntities6();

            //Fetch object from db
            Product p = db.Products.Find(id);

            p.Name        = product.Name;
            p.Price       = product.Price;
            p.TypeID      = product.TypeID;
            p.Description = product.Description;
            p.Image       = product.Image;

            db.SaveChanges();
            return(product.Name + " was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }