Esempio n. 1
0
    public string InsertCart(Cart cart)
    {
        try
        {
            GtgNordicEntities db = new GtgNordicEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return(cart.DatePurchased + " Was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Esempio n. 2
0
    public string InsertProductType(ProductType productType)
    {
        try
        {
            GtgNordicEntities db = new GtgNordicEntities();
            db.ProductTypes.Add(productType);
            db.SaveChanges();

            return(productType.Name + " Was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
Esempio n. 3
0
    public string DeleteCart(int id)
    {
        try
        {
            GtgNordicEntities db = new GtgNordicEntities();
            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);
        }
    }
Esempio n. 4
0
    public string DeleteProduct(int id)
    {
        try
        {
            GtgNordicEntities db      = new GtgNordicEntities();
            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);
        }
    }
Esempio n. 5
0
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GtgNordicEntities db = new GtgNordicEntities();
            //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);
        }
    }
Esempio n. 6
0
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            GtgNordicEntities db = new GtgNordicEntities();
            //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);
        }
    }
Esempio n. 7
0
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            GtgNordicEntities db = new GtgNordicEntities();
            //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);
        }
    }