Esempio n. 1
0
        public string UpdateProductType(int id, ProductType productType)
        {
            try
            {
                ProteinPowderEntities db = new ProteinPowderEntities();

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

                p.Name = productType.Name;


                db.SaveChanges();
                return(productType.Name + "was successfully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Esempio n. 2
0
        public string UpdateCart(int id, Cart cart)
        {
            try
            {
                ProteinPowderEntities db = new ProteinPowderEntities();

                //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 successfully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
        public string UpdateProduct(int id, Product product)
        {
            try
            {
                ProteinPowderEntities db = new ProteinPowderEntities();

                //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 successfully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }