Beispiel #1
0
        public async Task<ICollection<Model.Common.IDepartment>> GetRangeAsync(GenericPaging filter)
        {
            try
            {
                if (filter == null)
                    filter = new GenericPaging(1, 5);

                return Mapper.Map<ICollection<IDepartment>>(await repository.Where<Department>()
                    .OrderBy(t => t.departmentName)
                    .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize)
                    .Take(filter.PageSize)
                    .ToListAsync());
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Beispiel #2
0
        public async Task<ICollection<IEmployee>> GetRangeAsync(GenericPaging filter, string search)
        {
            try
            {
                if (filter == null)
                    filter = new GenericPaging(1, 5);

                return Mapper.Map<ICollection<IEmployee>>(await repository.Where<Employee>()
                    .Where(t => t.employeeName.Contains(search))
                    .OrderBy(t => t.employeeName)
                    .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize)
                    .Take(filter.PageSize)
                    .ToListAsync());
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Beispiel #3
0
            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<EmployeeModel> result = Mapper.Map<ICollection<EmployeeModel>>(await service.GetRangeAsync(filter));

                    return Request.CreateResponse(HttpStatusCode.OK, result);

                }
                catch (Exception ex)
                {

                    return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
                }
            }
Beispiel #4
0
 public async Task<ICollection<IEmployee>> GetRangeAsync(GenericPaging filter, string search)
 {
     return await repository.GetRangeAsync(filter, search);
 }
Beispiel #5
0
 public async Task<ICollection<Model.Common.IEmployee>> GetRangeAsync(GenericPaging filter)
 {
     return await repository.GetRangeAsync(filter);
 }