public List <ItemDTO> GetLastAddedItems(Status status) { var spec = new FilterItemSpecyfication(status); var items = _unitOfWork.ItemRepo.GetLatestAddedItems(spec, 4).ToList(); var result = _mapper.Map <List <Item>, List <ItemDTO> >(items); return(result); }
public PagedItemDTO GetItems(PagedItemCriteriaDTO dto) { var c = dto; var predicateSpec = new FilterItemSpecyfication(c.Status, c.CategoryId, c.SubcategoryId); var orderSpec = new OrderItemSpecyfication(c.SortBy); var items = _unitOfWork.ItemRepo.Find(predicateSpec, orderSpec); var result = new PagedItemDTO(); result.TotalPages = (int)Math.Ceiling((decimal)items.Count() / c.PageSize); items = items.Skip((c.PageNumber - 1) * c.PageSize).Take(c.PageSize).ToList(); result.Items = _mapper.Map <List <Item>, List <SimpleItemDTO> >(items.ToList()); return(result); }