public async Task <ActionResult> GetItems(ItemFilterDTO filter) { var items = await DataService.CallDataServiceList <ItemDTO>("Item", "GetItems", filter); return(new JsonResult { Data = items }); }
public DTOList <ItemDTO> GetItems(ItemFilterDTO filter) { DTOList <ItemDTO> retValue = null; using (var context = new DataAccessContext()) { var items = (from n in context.Items where n.CategoryId == filter.CategoryId && n.AssociatedUserId == null // no one has it checked out or requested select n).ToList(); if (filter.AgeGroupId > 0) { items = (from i in items where i.Item2AgeGroup.Count(n => n.AgeGroupId == filter.AgeGroupId) > 0 select i).ToList(); } if (filter.SubjectId > 0) { items = (from i in items where i.Item2Subject.Count(n => n.SubjectId == filter.SubjectId) > 0 select i).ToList(); } if (filter.LocationId > 0) { items = (from i in items where i.LocationId == filter.LocationId select i).ToList(); } retValue = retValue.DTOConvert(items); retValue.StatusMessage = $"Found {items.Count} items"; } return(retValue); }
public async Task <ActionResult <IEnumerable <ItemDTO> > > GetItemsByFilter(ItemFilterDTO filter) { if (!string.IsNullOrEmpty(filter.Color)) { return(filter.EndPrice == null ? (await dp.GetIEnumerableMapped <Item, ItemDTO>()) .Where(x => x.Price >= filter.StartPrice && x.Color.Contains(filter.Color)) .ToList() : (await dp.GetIEnumerableMapped <Item, ItemDTO>()) .Where(x => x.Price >= filter.StartPrice && x.Price <= filter.EndPrice && x.Color.Contains(filter.Color)) .ToList()); } else { return(filter.EndPrice == null ? (await dp.GetIEnumerableMapped <Item, ItemDTO>()) .Where(x => x.Price >= filter.StartPrice) .ToList() : (await dp.GetIEnumerableMapped <Item, ItemDTO>()) .Where(x => x.Price >= filter.StartPrice && x.Price <= filter.EndPrice) .ToList()); } }