예제 #1
0
        public TableResultJson <ReplyCommentViewModel> GetReplyCommentPaged(TableRequest request)
        {
            var dataSource          = replyCommentRepository.GetAll().OrderByDescending(x => x.CreatedDate).ToList();
            var dataSourceViewModel = (mapper.Map <List <ReplyCommentViewModel> >(dataSource)).AsEnumerable();

            if (request.columns[1].search != null)
            {
                var _value1 = request.columns[1].search.value;
                if (!string.IsNullOrEmpty(_value1))
                {
                    dataSourceViewModel = dataSourceViewModel.Where(x => x.OId.Contains(_value1));
                }
            }

            if (request.columns[2].search != null)
            {
                var _value2 = request.columns[2].search.value;
                if (!string.IsNullOrEmpty(_value2))
                {
                    dataSourceViewModel = dataSourceViewModel.Where(x => x.AuthorName.Contains(_value2));
                }
            }

            if (request.columns[3].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[3].search.value))
                {
                    var dt = DateTime.TryParseExact(request.columns[3].search.value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var datetime);
                    if (dt)
                    {
                        dataSourceViewModel = dataSourceViewModel.Where(x => x.CreatedDate.Value.Date == datetime);
                    }
                }
            }

            if (request.columns[8].search != null)
            {
                var _value4 = request.columns[8].search.value;
                if (!string.IsNullOrEmpty(_value4))
                {
                    dataSourceViewModel = dataSourceViewModel.Where(x => x.Content.Contains(_value4));
                }
            }

            var response = new TableResultJson <ReplyCommentViewModel>();

            response.draw            = request.draw;
            response.recordsFiltered = dataSourceViewModel.Count();
            dataSourceViewModel      = dataSourceViewModel.Skip(request.start).Take(request.length);
            response.data            = dataSourceViewModel.ToList();

            response.data.ForEach(x => { x.Index = response.data.IndexOf(x) + request.start + 1; });
            return(response);
        }
예제 #2
0
        public TableResultJson <LevelViewModel> GetAllLevel(TableRequest request)
        {
            var dataSource          = levelRepository.GetAll();
            var dataSourceViewModel = mapper.Map <List <LevelViewModel> >(dataSource).AsEnumerable();
            var response            = new TableResultJson <LevelViewModel>
            {
                draw            = request.draw,
                recordsFiltered = dataSourceViewModel.Count()
            };

            dataSourceViewModel = dataSourceViewModel.Skip(request.start).Take(request.length);
            response.data       = dataSourceViewModel.ToList();
            response.data.ForEach(x => { x.Index = response.data.IndexOf(x) + request.start + 1; });
            return(response);
        }
예제 #3
0
        public TableResultJson <FieldViewModel> GetAllField(TableRequest request)
        {
            var dataSource          = fieldRepository.GetAll().OrderByDescending(x => x.CreatedDate);
            var dataSourceViewModel = mapper.Map <List <FieldViewModel> >(dataSource).AsEnumerable();
            var response            = new TableResultJson <FieldViewModel>
            {
                draw            = request.draw,
                recordsFiltered = dataSourceViewModel.Count()
            };

            dataSourceViewModel = dataSourceViewModel.Skip(request.start).Take(request.length);
            response.data       = dataSourceViewModel.ToList();
            response.data.ForEach(x => { x.Index = response.data.IndexOf(x) + request.start + 1; });
            return(response);
        }
예제 #4
0
        public TableResultJson <ViolenceWordViewModel> GetViolenceWordPaged(TableRequest request)
        {
            var dataSource          = violenceWordRepository.GetAll();
            var dataSourceViewModel = mapper.Map <IEnumerable <ViolenceWordViewModel> >(dataSource);

            var response = new TableResultJson <ViolenceWordViewModel>();

            response.draw            = request.draw;
            response.recordsFiltered = dataSourceViewModel.Count();
            dataSourceViewModel      = dataSourceViewModel.Skip(request.start).Take(request.length);
            response.data            = dataSourceViewModel.ToList();

            foreach (var item in response.data)
            {
                item.Index = response.data.IndexOf(item) + request.start + 1;
            }
            return(response);
        }
예제 #5
0
        public TableResultJson <LoggingViewModel> GetPaged(TableRequest request)
        {
            var dataSource = loggingRepository.GetAll().OrderByDescending(x => x.CreatedDate.Value).AsEnumerable();

            if (request.columns[0].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[0].search.value))
                {
                    dataSource = dataSource.Where(x => x.RequestMethod.Contains(request.columns[0].search.value));
                }
            }

            if (request.columns[1].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[1].search.value))
                {
                    dataSource = dataSource.Where(x => x.Location.Contains(request.columns[1].search.value));
                }
            }

            if (request.columns[3].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[3].search.value))
                {
                    dataSource = dataSource.Where(x => x.StatusCode.ToString().Contains(request.columns[3].search.value));
                }
            }
            var response = new TableResultJson <LoggingViewModel>();

            response.draw            = request.draw;
            response.recordsFiltered = dataSource.Count();

            dataSource    = dataSource.Skip(request.start).Take(request.length);
            response.data = mapper.Map <List <LoggingViewModel> >(dataSource.ToList());
            foreach (LoggingViewModel item in response.data)
            {
                item.Index = response.data.IndexOf(item) + request.start + 1;
            }
            return(response);
        }
예제 #6
0
        public TableResultJson <UserViewModel> GetUserPaged(TableRequest request)
        {
            var dataSource = userRepository.GetAll().OrderByDescending(x => x.CreatedDate).AsEnumerable();

            var dataSourceViewModels = mapper.Map <List <UserViewModel> >(dataSource).AsEnumerable();

            TableResultJson <UserViewModel> response = new TableResultJson <UserViewModel>();

            response.draw            = request.draw;
            response.recordsFiltered = dataSourceViewModels.Count();

            if (request.columns[1].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[1].search.value))
                {
                    dataSourceViewModels = dataSourceViewModels.Where(x => x.FullName.Contains(request.columns[1].search.value));
                }
            }

            if (request.columns[2].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[2].search.value))
                {
                    dataSourceViewModels = dataSourceViewModels.Where(x => x.Email.Contains(request.columns[2].search.value));
                }
            }

            if (request.columns[3].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[3].search.value))
                {
                    dataSourceViewModels = dataSourceViewModels.Where(x => x.PhoneNumber.Contains(request.columns[3].search.value));
                }
            }

            if (request.columns[4].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[4].search.value))
                {
                    dataSourceViewModels = dataSourceViewModels.Where(x => (x.FullAddress.Contains(request.columns[4].search.value)));
                }
            }

            if (request.columns[9].search != null)
            {
                var _value = request.columns[9].search.value;
                if (!string.IsNullOrEmpty(_value))
                {
                    if (_value != "5")
                    {
                        var _status = ItemStatus.TryParse(_value, out ItemStatus __status);
                        dataSourceViewModels = dataSourceViewModels.Where(x => x.Status == __status);
                    }
                }
            }

            dataSourceViewModels = dataSourceViewModels.Skip(request.start).Take(request.length);
            response.data        = dataSourceViewModels.ToList();

            foreach (UserViewModel item in response.data)
            {
                item.Index = response.data.IndexOf(item) + request.start + 1;
            }
            return(response);
        }
예제 #7
0
        public TableResultJson <ReportViewModel> GetReportPaged(TableRequest request)
        {
            var dataSource          = reportRepository.GetAll();
            var dataSourceViewModel = mapper.Map <List <ReportViewModel> >(dataSource).AsEnumerable();
            var response            = new TableResultJson <ReportViewModel>();

            if (request.columns[1].search != null)
            {
                var _value1 = request.columns[1].search.value;
                if (!string.IsNullOrEmpty(_value1))
                {
                    dataSourceViewModel = dataSourceViewModel.Where(x => x.OId.Contains(_value1));
                }
            }

            if (request.columns[2].search != null)
            {
                var _value2 = request.columns[2].search.value;
                if (!string.IsNullOrEmpty(_value2))
                {
                    dataSourceViewModel = dataSourceViewModel.Where(x => x.AuthorName.Contains(_value2));
                }
            }

            if (request.columns[5].search != null)
            {
                if (!string.IsNullOrEmpty(request.columns[4].search.value))
                {
                    var dt = DateTime.TryParseExact(request.columns[4].search.value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var datetime);
                    if (dt)
                    {
                        dataSourceViewModel = dataSourceViewModel.Where(x => x.CreatedDate.Value.Date == datetime);
                    }
                }
            }

            if (request.columns[6].search != null)
            {
                var _value3 = request.columns[6].search.value;
                if (!string.IsNullOrEmpty(_value3))
                {
                    if (_value3 == "true")
                    {
                        dataSourceViewModel = dataSourceViewModel.Where(x => x.IsApproved == true);
                    }
                    else if (_value3 == "false")
                    {
                        dataSourceViewModel = dataSourceViewModel.Where(x => x.IsApproved == false);
                    }
                }
            }

            response.draw            = request.draw;
            response.recordsFiltered = dataSourceViewModel.Count();
            dataSourceViewModel      = dataSourceViewModel.Skip(request.start).Take(request.length);
            response.data            = dataSourceViewModel.ToList();
            foreach (var item in response.data)
            {
                item.Index = response.data.IndexOf(item) + request.start + 1;
            }

            return(response);
        }