예제 #1
0
        public void AddProduct(ProductModel product)
        {
            LS_Product productEntity = new LS_Product();

            productEntity.ImagePath   = product.ImagePath;
            productEntity.Name        = product.Name;
            productEntity.Price       = product.Price;
            productEntity.Description = product.Description;

            using (DBDVEntities db = new DBDVEntities())
            {
                db.LS_Product.Add(productEntity);
                db.SaveChanges();
            }
        }
예제 #2
0
        public void AddOrder(ProductModel product, string id)
        {
            LS_Orders order = new LS_Orders();

            order.Id        = id;
            order.ProductId = product.Id;
            order.Quantity  = product.Quantity;
            order.Total     = product.Quantity * product.Price;

            using (DBDVEntities db = new DBDVEntities())
            {
                db.LS_Orders.Add(order);
                db.SaveChanges();
            }
        }
예제 #3
0
        public bool DeleteProduct(int productId)
        {
            using (DBDVEntities db = new DBDVEntities())
            {
                var result = db.LS_Product.SingleOrDefault(b => b.id == productId);

                if (result != null)
                {
                    result.IsDeleted = true;
                    db.SaveChanges();

                    return(true);
                }

                return(false);
            }
        }