示例#1
0
    public void InsertUserInformation(UserInformation info)
    {
        GarageEntities db = new GarageEntities();

        db.UserInformations.Add(info);
        db.SaveChanges();
    }
示例#2
0
        public void InsertUserDetail(UserDetail userDetail)
        {
            GarageEntities db = new GarageEntities();

            db.UserDetails.Add(userDetail);
            db.SaveChanges();
        }
示例#3
0
        public void InsertUserInformation(UserInformation info)
        {
            var context = new GarageEntities();

            context.UserInformation.AddOrUpdate(info);
            context.SaveChanges();
        }
示例#4
0
    public void UpdateQuantity(int id, int quantity)
    {
        GarageEntities db   = new GarageEntities(); // Connection to the DB
        Cart           cart = db.Carts.Find(id);

        cart.Amount = quantity;

        db.SaveChanges();
    }
示例#5
0
    public void UpdateQuantity(int id, int quantity)
    {
        GarageEntities db = new GarageEntities();
        Cart           p  = db.Carts.Find(id);

        p.Amount = quantity;

        db.SaveChanges();
    }
示例#6
0
        public void UpdateQuantity(int id, int quantity)
        {
            var context = new GarageEntities();

            var cart = context.Purchase.Find(id);

            cart.Amount = quantity;

            context.SaveChanges();
        }
示例#7
0
        public void MarkOrderAsPaid(IList <Purchase> carts)
        {
            var context = new GarageEntities();

            foreach (var cart in carts)
            {
                var oldCart = context.Purchase.Find(cart.ID);
                oldCart.Date     = DateTime.Now;
                oldCart.IsInCart = false;
            }

            context.SaveChanges();
        }
    public void MarkOrdersAsPaid(List<Cart> carts)
    {
        GarageEntities db = new GarageEntities();

        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 InsertCart(Cart cart)
    {
        try
        {
            GarageEntities db = new GarageEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return "Order was succesfully inserted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
    public string InsertCart(Cart cart)
    {
        try
        {
            GarageEntities db = new GarageEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return("Order was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
    public string InsertProductType(ProductType productType)
    {
        try
        {
            GarageEntities db = new GarageEntities();
            db.ProductTypes.Add(productType);
            db.SaveChanges();

            return productType.Name + "was succesfully inserted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
示例#12
0
 public string DeleteProduct(int id)
 {
     try
     {
         GarageEntities db   = new GarageEntities();
         var            prod = db.Product.Find(id);
         db.Product.Attach(prod);
         db.SaveChanges();
         return(prod.Name + "was succesfully removed");
     }
     catch (Exception e)
     {
         return("Error" + e);
     }
 }
示例#13
0
    public string InsertProduct(Product product)
    {
        try
        {
            GarageEntities db = new GarageEntities();
            db.Product.Add(product);
            db.SaveChanges();

            return(product.Name + "was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error" + e);
        }
    }
示例#14
0
 public string DeletePurchase(int id)
 {
     try
     {
         GarageEntities db       = new GarageEntities();
         var            purchase = db.Purchase.Find(id);
         db.Purchase.Attach(purchase);
         db.SaveChanges();
         return(purchase.Date + "was succesfully removed");
     }
     catch (Exception e)
     {
         return("Error" + e);
     }
 }
示例#15
0
        public string InsertPurchase(Purchase purchase)
        {
            try
            {
                GarageEntities db = new GarageEntities();
                db.Purchase.Add(purchase);
                db.SaveChanges();

                return(purchase.Date + "was succesfully inserted");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
示例#16
0
    public string InsertCart(Cart cart)
    {
        try
        {
            GarageEntities db = new GarageEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return("La orden fue agregada con exito");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
示例#17
0
    public void MarkOrdersAsPaid(List <Cart> carts)
    {
        GarageEntities db = new GarageEntities();

        if (carts != null)
        {
            foreach (Cart cart in carts)
            {
                Cart oldCart = db.Carts.Find(cart.ID);
                oldCart.DatePurchased = DateTime.Now;
                oldCart.IsInCart      = false;
            }
            db.SaveChanges();
        }
    }
示例#18
0
        public string InsertProduct(Product product)
        {
            try
            {
                GarageEntities db = new GarageEntities();
                db.Products.Add(product);
                db.SaveChanges();

                return(product.Name + " fue agregado con exito");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
        public string InsertPurchase(Purchase purchase)
        {
            try
            {
                GarageEntities db = new GarageEntities();
                db.Purchases.Add(purchase);
                BeforeInsert(purchase);
                db.SaveChanges();

                return(purchase.ID + " was succesufully inserted.");
            }
            catch (Exception e)
            {
                return("Error: " + e);
            }
        }
示例#20
0
        public string InsertProductType(ProductType producttype)
        {
            try
            {
                GarageEntities db = new GarageEntities();
                db.ProductTypes.Add(producttype);
                BeforeInsert(producttype);
                db.SaveChanges();

                return(producttype.ID + " was succesufully inserted.");
            }
            catch (Exception e)
            {
                return("Error: " + e);
            }
        }
示例#21
0
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageEntities db     = new GarageEntities();
            var            toEdit = db.ProductType.FirstOrDefault(p => p.ID == id);
            toEdit.Name = productType.Name;
            db.SaveChanges();

            return(productType.Name + "was succesfully updated.");
        }
        catch (Exception e)
        {
            return("Error" + e);
        }
    }
示例#22
0
        public string UpdatePurchase(int id, Purchase purchase)
        {
            try
            {
                GarageEntities db     = new GarageEntities();
                var            toEdit = db.Purchase.FirstOrDefault(p => p.ID == id);
                toEdit.Amount   = purchase.Amount;
                toEdit.Date     = purchase.Date;
                toEdit.IsInCart = purchase.IsInCart;
                db.SaveChanges();

                return(purchase.Date + "was succesfully updated.");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
    public string DeleteProductType(int id)
    {
        try
        {
            GarageEntities db = new GarageEntities();
            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 DeleteCart(int id)
    {
        try
        {
            GarageEntities db = new GarageEntities();
            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;
        }
    }
示例#25
0
    public string DeleteProductType(int id)
    {
        try
        {
            GarageEntities db          = new GarageEntities();
            ProductType    productType = db.ProductTypes.Find(id);

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

            return(productType.Name + "fue borrado con exito");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
示例#26
0
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageEntities db = new GarageEntities();

            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + "fue actualizado con exito");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
        public string DeleteProduct(int id)
        {
            try
            {
                GarageEntities db      = new GarageEntities();
                Product        product = db.Products.Find(id);

                db.Products.Attach(product);
                db.Products.Remove(product);
                db.SaveChanges();

                return(product.Name + " was succesfully deleted");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
示例#28
0
        public string UpdateProductType(int id, ProductType producttype)
        {
            try
            {
                GarageEntities db  = new GarageEntities();
                ProductType    tmp = db.ProductTypes.Find(id);

                tmp.Name = producttype.Name;

                BeforeUpdate(producttype);
                db.SaveChanges();
                return(producttype.ID + " was succesufully updated.");
            }
            catch (Exception e)
            {
                return("Error: " + e);
            }
        }
示例#29
0
    public string DeleteCart(int id)
    {
        try
        {
            GarageEntities db   = new GarageEntities();
            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);
        }
    }
示例#30
0
        public string DeleteProductType(int id)
        {
            try
            {
                GarageEntities db          = new GarageEntities();
                ProductType    producttype = db.ProductTypes.Find(id);

                db.ProductTypes.Attach(producttype);
                db.ProductTypes.Remove(producttype);
                BeforeDelete(id);
                db.SaveChanges();

                return(producttype.ID + " was succesufully deleted.");
            }
            catch (Exception e)
            {
                return("Error: " + e);
            }
        }
示例#31
0
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageEntities db = new GarageEntities();

            //Fetch object from db
            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + "was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageEntities db = new GarageEntities();

            //Fetch object from db
            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

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

        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
示例#33
0
    public string InsertCart(Cart cart)
    {
        try
        {
            GarageEntities db = new GarageEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            String itm = "s were";
            if (cart.Amount == 1)
            {
                itm = " was";
            }
            return(cart.Amount.ToString() + " item" + itm + " succesfully added to cart");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
示例#34
0
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            GarageEntities db     = new GarageEntities();
            var            toEdit = db.Product.FirstOrDefault(p => p.ID == id);
            toEdit.Name        = product.Name;
            toEdit.Description = product.Description;
            toEdit.Image       = product.Image;
            toEdit.Price       = product.Price;
            toEdit.TypeID      = product.TypeID;
            db.Product.AddOrUpdate(toEdit);
            db.SaveChanges();

            return(product.Name + "was succesfully updated.");
        }
        catch (Exception e)
        {
            return("Error" + e);
        }
    }
示例#35
0
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            GarageEntities db = new GarageEntities();

            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 + " fue actualizado con exito");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
示例#36
0
        public string UpdateProduct(int id, Product product)
        {
            try
            {
                GarageEntities db  = new GarageEntities();
                Product        tmp = db.Products.Find(id);

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

                BeforeUpdate(product);
                db.SaveChanges();
                return(product.ID + " was succesufully updated.");
            }
            catch (Exception e)
            {
                return("Error: " + e);
            }
        }
        public string UpdateProduct(int id, Product product)
        {
            try
            {
                GarageEntities db = new GarageEntities();

                //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;
            }
        }
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            GarageEntities db = new GarageEntities();

            //Fetch object from db
            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;
        }
    }
    public void UpdateQuantity(int id, int quantity)
    {
        GarageEntities db = new GarageEntities();
        Cart p = db.Carts.Find(id);
        p.Amount = quantity;

        db.SaveChanges();
    }