Esempio n. 1
0
    public string InsertPurchase(Purchase purchase)
    {
        try
        {
            TshirtDBEntities db = new TshirtDBEntities();
            db.Purchases.Add(purchase);
            db.SaveChanges();

            return(purchase.Date + " was succesfully added!");
        }
        catch (Exception e)
        {
            return("Error " + e);
        }
    }
Esempio n. 2
0
    public string InsertProduct(Product product)
    {
        try
        {
            TshirtDBEntities db = new TshirtDBEntities();
            db.Products.Add(product);
            db.SaveChanges();

            return(product.Name + " was succesfully added!");
        }
        catch (Exception e)
        {
            return("Error " + e);
        }
    }
Esempio n. 3
0
    public string InsertSize(Size size)
    {
        try
        {
            TshirtDBEntities db = new TshirtDBEntities();
            db.Sizes.Add(size);
            db.SaveChanges();

            return(size.Name + " was succesfully added!");
        }
        catch (Exception e)
        {
            return("Error " + e);
        }
    }
Esempio n. 4
0
    public string DeletePurchase(int id)
    {
        try
        {
            TshirtDBEntities db = new TshirtDBEntities();
            Purchase         p  = db.Purchases.Find(id);

            db.Purchases.Attach(p);
            db.Purchases.Remove(p);
            db.SaveChanges();
            return(p.Date + " was succesfully deleted!");
        }
        catch (Exception e)
        {
            return("Error " + e);
        }
    }
Esempio n. 5
0
    public string UpdateSize(int id, Size size)
    {
        try
        {
            TshirtDBEntities db = new TshirtDBEntities();
            Size             p  = db.Sizes.Find(id);

            p.Name = size.Name;
            db.SaveChanges();

            return(size.Name + " was succesfully updated!");
        }
        catch (Exception e)
        {
            return("Error " + e);
        }
    }
Esempio n. 6
0
    public string UpdatePurchase(int id, Purchase purchase)
    {
        try
        {
            TshirtDBEntities db = new TshirtDBEntities();
            Purchase         p  = db.Purchases.Find(id);

            p.Date      = purchase.Date;
            p.Amount    = purchase.Amount;
            p.IsInCart  = purchase.IsInCart;
            p.ProductID = purchase.ProductID;
            db.SaveChanges();
            return(purchase.Date + " was succesfully updated!");
        }
        catch (Exception e)
        {
            return("Error " + e);
        }
    }
Esempio n. 7
0
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            TshirtDBEntities db = new TshirtDBEntities();
            Product          p  = db.Products.Find(id);

            p.Name        = product.Name;
            p.Price       = product.Price;
            p.Image       = product.Image;
            p.Description = product.Description;
            p.TypeID      = product.TypeID;
            db.SaveChanges();

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