Beispiel #1
0
        public ProductColor Added()
        {
            ProductColor oProductColor = new ProductColor();

            oProductColor = new ProductColorGetService(_productColor).GetColorByColorId();

            if (oProductColor.ProductColorId > 0)
            {
                oProductColor = new ProductColorModifiedService(_productColor).Modified();
            }
            else
            {
                oProductColor = new ProductColorAddService(_productColor).Added();
            }

            return(oProductColor);
        }
Beispiel #2
0
        public ProductColor Removed()
        {
            ProductColor oProduct = new ProductColor();

            oProduct = new ProductColorGetService(_productColor).GetColorByColorId();
            if (oProduct.ProductColorId > 0)
            {
                using (var context = new ColorStitchDataContext())
                {
                    using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
                    {
                        IRepositoryAsync <ProductColor> productRepository = new Repository <ProductColor>(context, unitOfWork);
                        productRepository.Delete(oProduct);
                        unitOfWork.SaveChanges();
                    }
                }
            }
            return(oProduct);
        }
        public ProductColor Modified()
        {
            ProductColor oProductEntity = new ProductColor();

            using (var context = new ColorStitchDataContext())
            {
                using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
                {
                    IRepositoryAsync <ProductColor> productRepository = new Repository <ProductColor>(context, unitOfWork);
                    oProductEntity = new ProductColorGetService(_productColor).GetColorByColorId();


                    oProductEntity.Product         = _productColor.Product;
                    oProductEntity.ColorName       = _productColor.ColorName;
                    oProductEntity.ProductQuantity = _productColor.ProductQuantity;
                    oProductEntity.ObjectState     = ObjectState.Modified;


                    productRepository.Update(oProductEntity);
                    unitOfWork.SaveChanges();
                }
            }
            return(oProductEntity);
        }