public int GetAllItemsInPromotionCount(MainColourType colour, MainMaterialType material) { var items = this.data.Items.GetAll(i => i.Discount != 0 && !i.IsDeleted && i.Quantity != 0); if (colour != 0) { items = items.Where(i => i.MainColour == colour); } if (material != 0) { items = items.Where(i => i.MainMaterial == material); } return(items.Count()); }
public int GetAllItemsCount(MainColourType colour, MainMaterialType material) { var items = this.data.Items.GetAll(); if (colour != 0) { items = items.Where(i => i.MainColour == colour); } if (material != 0) { items = items.Where(i => i.MainMaterial == material); } return(items.Count()); }
public int GetItemsOfTypeCount(ItemType itemType, MainColourType colour, MainMaterialType material) { Validator.ValidateNullArgument(itemType, "itemType"); var items = this.data.Items.GetAll(i => i.ItemType == itemType); if (colour != 0) { items = items.Where(i => i.MainColour == colour); } if (material != 0) { items = items.Where(i => i.MainMaterial == material); } return(items.Count()); }
public void GetAllItemsInPromotionCount_ShouldCallItemRepoGetAll_TimesOnce() { // Arrange var itemCollection = new List <Item>(); MainColourType colour = MainColourType.Red; MainMaterialType material = MainMaterialType.Swarovski; this.itemRepoMock.Setup(r => r.GetAll(It.IsAny <Expression <Func <Item, bool> > >())).Returns(itemCollection); this.dataMock.SetupGet(d => d.Items).Returns(this.itemRepoMock.Object); var itemService = new ItemService(this.dataMock.Object); // Act var count = itemService.GetAllItemsInPromotionCount(colour, material); // Assert this.itemRepoMock.Verify(r => r.GetAll(It.IsAny <Expression <Func <Item, bool> > >()), Times.Once); }
public IEnumerable <Item> GetNewestItems(int pageNumber, MainColourType colourType, MainMaterialType materialType) { Validator.ValidateRange(pageNumber, 1, int.MaxValue, "pageNumber"); var itemsList = this.data.Items.GetAll(i => !i.IsDeleted && i.Quantity != 0, i => i.DateAdded); if (colourType != 0) { itemsList = itemsList.Where(i => i.MainColour == colourType); } if (materialType != 0) { itemsList = itemsList.Where(i => i.MainMaterial == materialType); } return(itemsList .OrderByDescending(i => i.DateAdded) .Skip((pageNumber - 1) * ServerConstants.ItemsOnPage) .Take(ServerConstants.ItemsOnPage) .ToList()); }