Exemple #1
0
        public JsonResult GetAllJobType()
        {
            try
            {
                var draw = HttpContext.Request.Query["draw"].FirstOrDefault();
                // Skiping number of Rows count
                var start = Request.Query["start"].FirstOrDefault();
                // Paging Length 10,20
                var length = Request.Query["length"].FirstOrDefault();
                // Sort Column Name
                // Sort Column Direction ( asc ,desc)
                var sortColumnDirection = Request.Query["order[0][dir]"].FirstOrDefault();
                // Search Value from (Search box)
                var searchValue = Request.Query["search[value]"].FirstOrDefault();

                //Paging Size (10,20,50,100)
                var pageSize = length != null?Convert.ToInt32(length) : 0;

                var skip = start != null?Convert.ToInt32(start) : 0;

                var recordsTotal = 0;

                var listOfJobType = new List <JobType>();

                listOfJobType = _lookUpService.GetAllJobType().Result;

                // Getting all Customer data  z
                var alljobType = listOfJobType;

                //Search
                if (!string.IsNullOrEmpty(searchValue))
                {
                    alljobType = alljobType.Where(m =>
                                                  m.JobTypeCode == searchValue ||
                                                  m.JobTypeDesc == searchValue)
                                 as List <JobType>;
                }

                //total number of rows count
                recordsTotal = alljobType.Count();
                //Paging
                var dataList = alljobType.Skip(skip).Take(pageSize).ToList();
                //Returning Json Data
                return(Json(new
                            { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = alljobType }));
            }
            catch (Exception)
            {
                throw;
            }
        }