Example #1
0
        public void InsertUserInformation(UserInformation info)
        {
            GarageDBEntities3 db = new GarageDBEntities3();

            db.UserInformation.Add(info);
            db.SaveChanges();
        }
Example #2
0
        public void UpdateQuantity(int id, int quantity)
        {
            GarageDBEntities3 db       = new GarageDBEntities3();
            Purchase          purchase = db.Purchase.Find(id);

            purchase.Amount = quantity;
            db.SaveChanges();
        }
Example #3
0
 public string InsertProductType(ProductType productType)
 {
     try
     {
         GarageDBEntities3 db = new GarageDBEntities3();
         db.ProductType.Add(productType);
         db.SaveChanges();
         return(productType.Name + " was succesfully inserted");
     }
     catch (Exception e)
     {
         return("Error" + e);
     }
 }
Example #4
0
 public string InsertPurchase(Purchase purchase)
 {
     try
     {
         GarageDBEntities3 db = new GarageDBEntities3();
         db.Purchase.Add(purchase);
         db.SaveChanges();
         return(purchase.Date + " was succesfully inserted");
     }
     catch (Exception e)
     {
         return("Error" + e);
     }
 }
Example #5
0
        public void MarkOrderAsPaid(List <Purchase> purchases)
        {
            GarageDBEntities3 db = new GarageDBEntities3();

            if (purchases != null)
            {
                foreach (Purchase purchase in purchases)
                {
                    Purchase oldpurchase = db.Purchase.Find(purchase.ID);
                    oldpurchase.Date     = DateTime.Now;
                    oldpurchase.IsInCart = false;
                }
                db.SaveChanges();
            }
        }
Example #6
0
        public string DeleteProductType(int id)
        {
            try
            {
                GarageDBEntities3 db          = new GarageDBEntities3();
                ProductType       productType = db.ProductType.Find(id);

                db.ProductType.Attach(productType);
                db.ProductType.Attach(productType);
                db.SaveChanges();

                return(productType.Name + " was successully deleted");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
Example #7
0
        public string DeletePurchase(int id)
        {
            try
            {
                GarageDBEntities3 db       = new GarageDBEntities3();
                Purchase          purchase = db.Purchase.Find(id);

                db.Purchase.Attach(purchase);
                db.Purchase.Remove(purchase);
                db.SaveChanges();

                return(purchase.Date + " was successully deleted");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
Example #8
0
        public string UpdateProductType(int id, ProductType productType)
        {
            try
            {
                GarageDBEntities3 db = new GarageDBEntities3();

                ProductType p = db.ProductType.Find(id);
                p.Name = productType.Name;


                db.SaveChanges();

                return(productType.Name + " was successfully updated");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
Example #9
0
        public string UpdateProduct(int id, Product product)
        {
            try
            {
                GarageDBEntities3 db = new GarageDBEntities3();

                Product p = db.Product.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 successfully updated");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
Example #10
0
        public string UpdatePurchase(int id, Purchase purchase)
        {
            try
            {
                GarageDBEntities3 db = new GarageDBEntities3();

                Purchase p = db.Purchase.Find(id);
                p.Date       = purchase.Date;
                p.CustomerID = purchase.CustomerID;
                p.Amount     = purchase.Amount;
                p.IsInCart   = purchase.IsInCart;
                p.ProductID  = purchase.ProductID;

                db.SaveChanges();

                return(purchase.Date + " was successfully updated");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }