/// <summary> /// Get collection of todos/tasks /// </summary> /// <param name="filter">Filter</param> /// <returns>Collection of todos</returns> public async Task<ICollection<Model.Common.ITodo>> GetRangeAsync(GenericPaging filter) { try { if (filter == null) filter = new GenericPaging(1, 5); return Mapper.Map<ICollection<ITodo>>(await repository.Where<TodoEntity>() .Include(item => item.User) .OrderBy(t => t.Title) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize) .ToListAsync()); } catch (Exception ex) { throw ex; } }
public async Task<HttpResponseMessage> Get(int pageNumber, int pageSize) { try { if (pageNumber < 1 || pageSize < 1) { pageSize = 1; pageNumber = 1; } GenericPaging filter = new GenericPaging(pageNumber, pageSize); ICollection<TodoModel> result = Mapper.Map<ICollection<TodoModel>>(await service.GetRangeAsync(filter)); return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
/// <summary> /// Get collection of todos /// </summary> /// <param name="filter">Filter options</param> /// <param name="userId">Get task/todo that belongs to logged user</param> /// <returns>Todo colletion</returns> public async Task<ICollection<ITodo>> GetTaskAsync(GenericPaging filter, string userId) { return await repository.GetTaskAsync(filter, userId); }
/// <summary> /// Get collection of todos /// </summary> /// <param name="filter">Filter options</param> /// <param name="search">String to search by</param> /// <returns>Todo colletion</returns> public async Task<ICollection<ITodo>> GetRangeAsync(GenericPaging filter, string search) { return await repository.GetRangeAsync(filter, search); }
/// <summary> /// Get collection of todos/tasks /// </summary> /// <param name="filer">Filter options</param> /// <returns>Todo collection</returns> public async Task<ICollection<Model.Common.ITodo>> GetRangeAsync(GenericPaging filter) { return await repository.GetRangeAsync(filter); }
/// <summary> /// Get collection of todos /// </summary> /// <param name="filter">Filter with pagenumber and size</param> /// <param name="search">Search userId</param> /// <returns>Todos collection</returns> public async Task<ICollection<ITodo>> GetTaskAsync(GenericPaging filter, string userId) { try { if (filter == null) filter = new GenericPaging(1, 5); return Mapper.Map<ICollection<ITodo>>(await repository.Where<TodoEntity>() .Where(t => t.UserId==userId || t.AssignedToUserId == userId) .OrderBy(t => t.Title) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize) .Include(item => item.User) .ToListAsync()); } catch (Exception ex) { throw ex; } }