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

        db.UserInformations.Add(info);
        db.SaveChanges();
    }
Example #2
0
    public void UPdateQuantity(int id, int quantity)
    {
        GameCenterDBEntities db = new GameCenterDBEntities();
        Cart cart = db.Carts.Find(id);

        cart.Amount = quantity;

        db.SaveChanges();
    }
    public string InsertProductType(ProductType productType)
    {
        try
        {
            GameCenterDBEntities db = new GameCenterDBEntities();
            db.ProductTypes.Add(productType);
            db.SaveChanges();

            return(productType.Name + " was succesfully inserted.");
        }
        catch (Exception e)
        {
            return("Error" + e);
        }
    }
Example #4
0
    public void MarkOrdersAsPaid(List <Cart> carts)
    {
        GameCenterDBEntities db = new GameCenterDBEntities();

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

            db.SaveChanges();
        }
    }
Example #5
0
    public string InsertCart(Cart cart)
    {
        try
        {
            GameCenterDBEntities db = new GameCenterDBEntities();

            //Adding a cart
            db.Carts.Add(cart);
            db.SaveChanges();

            return(cart.DatePurchased + " was succesfully inserted.");
        }
        catch (Exception e)
        {
            return("Error" + e);
        }
    }
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GameCenterDBEntities db = new GameCenterDBEntities();

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

            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + " was succesfully updated.");
        }
        catch (Exception e)
        {
            return("Error" + e);
        }
    }
Example #7
0
    public string DeleteCart(int id)
    {
        try
        {
            GameCenterDBEntities db = new GameCenterDBEntities();

            //Finding the object that needs to be deleted
            Cart cart = db.Carts.Find(id);

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

            return(cart.DatePurchased + " was succesfully updated.");
        }
        catch (Exception e)
        {
            return("Error" + e);
        }
    }
Example #8
0
    public string DeleteProduct(int id)
    {
        try
        {
            GameCenterDBEntities db = new GameCenterDBEntities();

            //Finding the object that needs to be deleted
            Product product = db.Products.Find(id);

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

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

            //Fetch object from database
            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);
        }
    }
Example #10
0
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            GameCenterDBEntities db = new GameCenterDBEntities();

            //Fetch object from database
            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);
        }
    }