public void FindPicByIdTest() { ProductPhotoRepository repository = new ProductPhotoRepository(); var list = repository.FindPicById(27); Assert.IsTrue(list != null); }
public void FindByIdTest() { ProductPhotoRepository repository = new ProductPhotoRepository(); var photos = repository.FindById(2); Assert.IsTrue(photos.Count() > 0); }
public void GetAllTest() { ProductPhotoRepository repository = new ProductPhotoRepository(); var photos = repository.GetAll(); Assert.IsTrue(photos.Count() > 0); }
public ProductList FindByName(string ProductName) { string[] sizes = new[] { "XS", "S", "M", "L", "XL", "XXL" }; ProductPhotoRepository productPhotoRepository = new ProductPhotoRepository(); var items = repository.FindByName(ProductName).ToList(); items = items.Where((x) => x.Downtime == null).ToList(); ProductList productList = new ProductList() { ProductName = items[0].ProductName, UnitPrice = decimal.Round(items[0].UnitPrice), ProductDetails = items[0].ProductDetails, Size = items.Select(x => x.Size).Distinct().OrderBy(x => sizes.Contains(x)?"0":"1").ThenBy(x => Array.IndexOf(sizes, x)).ThenBy(x => x).ToList(), Color = items.Select(x => x.Color).Distinct().ToList(), }; productList.PhotoPath = new List <string>(); foreach (var item in items) { foreach (var photo in productPhotoRepository.FindById(item.ProductID)) { if (productList.PhotoPath.Any((x) => x == photo.PhotoPath) == false) { productList.PhotoPath.Add(photo.PhotoPath); } } } return(productList); }
public ProductManager() { _proRepo = new UserProductRepository(); _photoRepo = new ProductPhotoRepository(); _imM = new ImageManager(); _userM = new UserManager(); }
public void DeleteTest() { ProductPhotoRepository repository = new ProductPhotoRepository(); ProductPhoto model = new ProductPhoto { PhotoID = 2 }; repository.Delete(model); var photos = repository.FindById(1); Assert.IsTrue(photos.Count() > 0); }
public void CreateTest() { ProductPhotoRepository repository = new ProductPhotoRepository(); ProductPhoto model = new ProductPhoto { ProductID = 1, PhotoPath = "url" }; repository.Create(model); var photos = repository.FindById(1); Assert.IsTrue(photos.Count() == 4); }
public void UpdateTest() { ProductPhotoRepository repository = new ProductPhotoRepository(); ProductPhoto model = new ProductPhoto { PhotoID = 1, ProductID = 1, PhotoPath = "a" }; repository.Update(model); var photos = repository.FindById(1); Assert.IsTrue(photos.Count() > 0); }
public AWUnitOfWork(AWContext context) { _context = context; Address = new AddressRepository(context); BusinessEntity = new BusinessEntityRepository(context); BusinessEntityAddress = new BusinessEntityAddressRepository(context); PersonPhone = new PersonPhoneRepository(context); StateProvince = new StateProvinceRepository(context); Customer = new CustomerRepository(context); SalesPerson = new SalesPersonRepository(context); SalesOrderHeader = new SalesOrderHeaderRepository(context); SalesOrderDetail = new SalesOrderDetailRepository(context); ShoppingCartItem = new ShoppingCartItemRepository(context); SalesTerritory = new SalesTerritoryRepository(context); Product = new ProductRepository(context); ProductCategory = new ProductCategoryRepository(context); ProductDescription = new ProductDescriptionRepository(context); ProductInventory = new ProductInventoryRepository(context); ProductListPriceHistory = new ProductListPriceHistoryRepository(context); ProductPhoto = new ProductPhotoRepository(context); ProductProductPhoto = new ProductProductPhotoRepository(context); Person = new PersonRepository(context); }