Пример #1
0
        public long SaveNewProduct(Products objnewProduct)
        {
            long result = 0;

            try
            {
                Products objProducts = new Products();
                using (var ctx = new dbShopBridgeEntities())
                {
                    if (objnewProduct != null)
                    {
                        ctx.ShopInventories.AddObject(new ShopInventory()
                        {
                            ItemType    = objnewProduct.ItemType,
                            ItemName    = objnewProduct.ItemName,
                            Price       = objnewProduct.Price,
                            Description = objnewProduct.Description,
                            CreatedBy   = objnewProduct.CreatedBy,
                            Quantity    = objnewProduct.Quantity,
                            CreatedDate = DateTime.Now
                        });
                        result = ctx.SaveChanges();
                        //result= objShopInventory.ID;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #2
0
        public long UpdateProduct(Products objProducts)
        {
            long result = 0;

            try
            {
                using (var ctx = new dbShopBridgeEntities())
                {
                    var objprod = ctx.ShopInventories
                                  .Where(s => s.ID == objProducts.ID)
                                  .FirstOrDefault();
                    if (objprod != null)
                    {
                        objprod.ItemType     = objProducts.ItemType;
                        objprod.ItemName     = objProducts.ItemName;
                        objprod.Price        = objProducts.Price;
                        objprod.Description  = objProducts.Description;
                        objprod.Quantity     = Convert.ToInt64(objProducts.Quantity);
                        objprod.ModifiedDate = DateTime.Now;
                        objprod.ModifiedBy   = objProducts.ModifiedBy;
                        ctx.SaveChanges();
                        result = 1;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public long DeleteProduct(long id)
        {
            long result = 0;

            try
            {
                Products objProducts = new Products();
                using (var ctx = new dbShopBridgeEntities())
                {
                    var obj = ctx.ShopInventories
                              .Where(s => s.ID == id)
                              .FirstOrDefault();
                    ctx.ShopInventories.DeleteObject(obj);
                    ctx.SaveChanges();

                    result = 1;
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }