public List <Product> GetsData() { List <Product> productList = new List <Product>(); using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Product> productRepository = new Repository <Product>(context, unitOfWork); productList = productRepository.Queryable().Include(x => x.ProductColors).ToList(); if (productList == null) { productList = new List <Product>(); } } } return(productList); }
public List <Product> GetsProductByName() { List <Product> productList = new List <Product>(); using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Product> productRepository = unitOfWork.RepositoryAsync <Product>(); productList = productRepository.Queryable().Where(p => p.ProductName.Contains(_product.ProductName)).ToList(); if (productList == null) { productList = new List <Product>(); } } } return(productList); }
public List <Product> GetsAlreadyExistProductCode(string productCode) { List <Product> productList = new List <Product>(); using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Product> productRepository = unitOfWork.RepositoryAsync <Product>(); productList = productRepository.Queryable().Where(p => p.ProductCode.ToLower() == productCode.ToLower()).ToList(); if (productList == null) { productList = new List <Product>(); } } } return(productList); }
public Product GetProductByProductId() { Product oProduct = new Product(); using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Product> productRepository = new Repository <Product>(context, unitOfWork); oProduct = productRepository.Queryable().Where(p => p.ProductId == _product.ProductId).Include(x => x.ProductColors).FirstOrDefault(); if (oProduct == null) { oProduct = new Product(); } } } return(oProduct); }
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 Product Removed() { Product oProduct = new Product(); oProduct = new ProductAddModificationService(_product).GetProductByProductId(_product.ProductId); if (oProduct.ProductId > 0) { using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Product> productRepository = new Repository <Product>(context, unitOfWork); productRepository.Delete(_product); unitOfWork.SaveChanges(); } } } return(oProduct); }
public List <ProductColor> GetsColorByColorName() { List <ProductColor> productList = new List <ProductColor>(); using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <ProductColor> productRepository = unitOfWork.RepositoryAsync <ProductColor>(); productList = productRepository.Queryable().Where(p => p.ColorName.ToLower().Contains(_productColor.ColorName.ToLower())).Include(x => x.Product).ToList(); if (productList == null) { productList = new List <ProductColor>(); } } } return(productList); }
public Product Added() { Product oProduct = new Product(); using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Product> productRepository = new Repository <Product>(context, unitOfWork); oProduct = new Product { ProductName = _product.ProductName, ProductCode = _product.ProductCode, ProductPrice = _product.ProductPrice, ObjectState = ObjectState.Added, }; productRepository.Insert(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); }
public ProductColor Added() { ProductColor oProduct = new ProductColor(); using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <ProductColor> productRepository = new Repository <ProductColor>(context, unitOfWork); oProduct = new ProductColor { Product = _productColor.Product, ColorName = _productColor.ColorName, ProductQuantity = _productColor.ProductQuantity, ObjectState = ObjectState.Added, }; productRepository.Insert(oProduct); unitOfWork.SaveChanges(); } } return(oProduct); }
public Product Modified() { Product oProductEntity = new Product(); using (var context = new ColorStitchDataContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Product> productRepository = new Repository <Product>(context, unitOfWork); oProductEntity = new ProductGetService(_product).GetProductByProductId(); oProductEntity.ProductName = _product.ProductName; oProductEntity.ProductCode = _product.ProductCode; oProductEntity.ProductPrice = _product.ProductPrice; oProductEntity.ObjectState = ObjectState.Modified; productRepository.Update(oProductEntity); unitOfWork.SaveChanges(); } } return(oProductEntity); }