public async Task <IActionResult> FindPagination(Pagination pagination)
        {
            ResponseHelper objHelper = new ResponseHelper();

            try
            {
                ReturnBy <Email_ConfigView> vList = new ReturnBy <Email_ConfigView>();
                vList.list = await Email_ConRepo.FindPaginated(pagination.PageIndex, pagination.PageSize, pagination.CommonSearch);

                if (vList.list.Count() == 0)
                {
                    objHelper.Status  = StatusCodes.Status200OK;
                    objHelper.Message = "Get Empty Data";
                }
                else
                {
                    vList.RecordCount = Email_ConRepo.RecordCount(pagination.CommonSearch);
                    objHelper.Status  = StatusCodes.Status200OK;
                    objHelper.Message = "Get Successfully";
                    objHelper.Data    = vList;
                }
                return(Ok(objHelper));
            }
            catch (Exception ex)
            {
                objHelper.Status  = StatusCodes.Status500InternalServerError;
                objHelper.Message = ex.Message;
                return(StatusCode(StatusCodes.Status500InternalServerError, objHelper));
            }
        }
Example #2
0
        //[ServiceFilter(typeof(ActionFilters.TokenVerify))]
        //[TypeFilter(typeof(ActionFilters.RolesValidate), Arguments = new object[] { "User", EnumPermission.View })]
        public IActionResult FindPagination(Pagination pagination)
        {
            ResponseHelper objResHelper = new ResponseHelper();

            try
            {
                ReturnBy <UserView> vList = new ReturnBy <UserView>();
                vList.list = userRepository.FindPaginated(pagination.PageIndex, pagination.PageSize, pagination.CommonSearch);
                if (vList.list.Count() == 0)
                {
                    objResHelper.Status  = StatusCodes.Status200OK;
                    objResHelper.Message = "Get Empty Data";
                }
                else
                {
                    //vList.RecordCount = userRepository.RecordCount(pagination.CommonSearch);
                    objResHelper.Status  = StatusCodes.Status200OK;
                    objResHelper.Message = "Get Successfully";
                    objResHelper.Data    = vList;
                }
                return(Ok(objResHelper));
            }
            catch (Exception ex)
            {
                objResHelper.Status  = StatusCodes.Status500InternalServerError;
                objResHelper.Message = ex.Message;
                return(StatusCode(StatusCodes.Status500InternalServerError, objResHelper));
            }
        }
        //[TypeFilter(typeof(ActionFilters.RolesValidate), Arguments = new object[] { "Category", EnumPermission.View })]
        public async Task <IActionResult> FindPagination(Pagination pagination)
        {
            ResponseHelper objHelper = new ResponseHelper();

            try
            {
                ReturnBy <Category> vList = new ReturnBy <Category>();
                vList.list = await categoryRepository.FindPaginated(pagination.PageIndex, pagination.PageSize, pagination.CommonSearch);

                vList.RecordCount = categoryRepository.RecordCount(pagination.CommonSearch);
                objHelper.Status  = StatusCodes.Status200OK;
                objHelper.Message = "Get Successfully";
                objHelper.Data    = vList;

                return(Ok(objHelper));
            }
            catch (Exception ex)
            {
                objHelper.Status  = StatusCodes.Status500InternalServerError;
                objHelper.Message = ex.Message;
                return(StatusCode(StatusCodes.Status500InternalServerError, objHelper));
            }
        }
        public async Task <ReturnBy <Employee> > GetPaginated(PaginationBy search)
        {
            try
            {
                string strOrder = string.IsNullOrEmpty(search.OrderBy) ? "Emp_Id" : search.OrderBy;
                string strWhere = Common.Search.WhereString(search);

                IEnumerable <Employee> vEmployee;
                if (!String.IsNullOrEmpty(search.CommonSearch))
                {
                    vEmployee = adbContext.employee.Where(w => new[] { w.Emp_Code, Convert.ToString(w.Emp_Id), Convert.ToString(w.Company_Id), Convert.ToString(w.Site_Id), Convert.ToString(w.JD_Id), Convert.ToString(w.Dept_Id), Convert.ToString(w.Desig_Id), Convert.ToString(w.Zone_Id), Convert.ToString(w.Shift_Id) }.Any(a => a.Contains(search.CommonSearch.ToLower()))).OrderBy(strOrder).ToList();
                }

                else
                {
                    vEmployee = adbContext.employee.Where(strWhere).OrderBy(strOrder).ToList();
                }

                ReturnBy <Employee> vList = new ReturnBy <Employee>()
                {
                    list        = vEmployee.Skip(search.PageIndex * search.PageSize).Take(search.PageSize).ToList(),
                    RecordCount = vEmployee.Count()
                };

                if (vList.list == null || vList.RecordCount == 0)
                {
                    throw new RecoredNotFoundException("Get Data Empty");
                }

                return(await Task.FromResult(vList));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }