public async Task <List <MComment> > Get(CommentSearchRequest search)
        {
            var query = _context.Comments.AsQueryable();

            var list = await query.ToListAsync();

            return(_mapper.Map <List <MComment> >(list));
        }
Esempio n. 2
0
        public async Task <ActionResult> ListAjax(CommentSearchRequest search)
        {
            var comments = await _commentService.GetPagedListAsync(search);

            var viewModel = new CommentListViewModel
            {
                Comments      = comments.Comments,
                SearchRequest = search
            };

            return(PartialView("_ListAjax", viewModel));
        }
Esempio n. 3
0
        public async Task <CommentMainListViewModel> GetCommentForMainPagedListAsync(CommentSearchRequest request)
        {
            var result = _comment.Select(q => new CommentMainDetailViewModel
            {
                Id          = q.Id,
                Body        = q.Body,
                IsActive    = q.IsActive,
                PostId      = q.PostId,
                PostTitle   = q.Post.Title,
                CreatorName = q.Creator.NameForShow,
                CreatorId   = q.CreatorId,
                CreatedOn   = q.CreatedOn
            }).AsQueryable();

            if (!string.IsNullOrWhiteSpace(request.Body))
            {
                result = result.Where(a => a.Body.Contains(request.Body)).AsQueryable();
            }

            if (request.Post != null)
            {
                result = result.Where(a => a.PostId == request.Post).AsQueryable();
            }

            switch (request.IsActive)
            {
            case ActiveStatus.Enable:
                result = result.Where(a => a.IsActive).AsQueryable();
                break;

            case ActiveStatus.Disable:
                result = result.Where(a => !a.IsActive).AsQueryable();
                break;

            case ActiveStatus.All:
                break;
            }

            request.Total = result.Count();
            var resultsToSkip = (request.PageIndex - 1) * request.PageSize;
            var query         = await result
                                .OrderByDescending(r => r.Id)
                                .Skip(() => resultsToSkip)
                                .Take(() => request.PageSize)
                                .ToListAsync();

            return(new CommentMainListViewModel {
                Comments = query, SearchRequest = request
            });
        }
Esempio n. 4
0
        public async Task <ActionResult> Active(CommentSearchRequest search)
        {
            if (search.Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            await _commentService.Active(search.Id, long.Parse(User.Identity.GetUserId()));

            return(PartialView("_ListAjax", await _commentService.GetPagedListAsync(new CommentSearchRequest
            {
                PageIndex = search.PageIndex,
                Body = search.Body
            })));
        }
Esempio n. 5
0
        public List <Data.Model.Comment> Get(CommentSearchRequest request)
        {
            var query = _context.Comment
                        .Include(x => x.AppUser)
                        .AsQueryable();

            if (request.MovieAndTvshowId != 0)
            {
                query = query.Where(x => x.MovieAndTvshowId == request.MovieAndTvshowId);
            }
            if (request.AppUserId != 0)
            {
                query = query.Where(x => x.AppUserId == request.AppUserId);
            }

            return(_mapper.Map <List <Data.Model.Comment> >(query.ToList()));
        }
        private async void btnSearch_Click(object sender, EventArgs e)
        {
            var search = new CommentSearchRequest()
            {
                ManufacturerName = txtManufacturerName.Text,
                ModelName        = txtModelName.Text,
                FirstName        = txtFirstName.Text,
                LastName         = txtLastName.Text
            };

            if (chkDisable.Checked)
            {
                search.DateOfComment = null;
            }
            else
            {
                search.DateOfComment = dtOfComment.Value.Date;
            }

            var resultList = await _serviceComments.Get <List <Data.Model.Comment> >(search);

            List <frmAllCommentsVM> finalList = new List <frmAllCommentsVM>();

            foreach (var item in resultList)
            {
                frmAllCommentsVM form = new frmAllCommentsVM
                {
                    CommentId        = item.CommentId,
                    Description      = item.Description,
                    DateOfComment    = item.DateOfComment.Date,
                    FirstName        = item.Customer.FirstName,
                    LastName         = item.Customer.LastName,
                    ManufacturerName = item.Vehicle.VehicleModel.Manufacturer.ManufacturerName,
                    ModelName        = item.Vehicle.VehicleModel.ModelName
                };
                finalList.Add(form);
            }
            dgvComments.AutoGenerateColumns = false;
            dgvComments.DataSource          = finalList;
            if (finalList.Count == 0)
            {
                MessageBox.Show("There are no results for this search", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 7
0
        public async Task <CommentListViewModel> GetPagedListAsync(CommentSearchRequest request)
        {
            var result = _comment
                         .ProjectTo <CommentDetailViewModel>(_mappingEngine);

            if (!string.IsNullOrWhiteSpace(request.Body))
            {
                result = result.Where(a => a.Body.Contains(request.Body)).AsQueryable();
            }

            if (request.Post != null)
            {
                result = result.Where(a => a.Post.Id == request.Post).AsQueryable();
            }

            switch (request.IsActive)
            {
            case ActiveStatus.Enable:
                result = result.Where(a => a.IsActive).AsQueryable();
                break;

            case ActiveStatus.Disable:
                result = result.Where(a => !a.IsActive).AsQueryable();
                break;

            case ActiveStatus.All:
                break;
            }

            request.Total = result.Count();
            var resultsToSkip = (request.PageIndex - 1) * request.PageSize;
            var query         = await result
                                .OrderByDescending(r => r.Id)
                                .Skip(() => resultsToSkip)
                                .Take(() => request.PageSize)
                                .ToListAsync();

            return(new CommentListViewModel {
                Comments = query, SearchRequest = request
            });
        }
 public async Task <List <MComment> > Get([FromQuery] CommentSearchRequest search)
 {
     return(await _service.Get(search));
 }
 public List <Data.Model.Comment> Get([FromQuery] CommentSearchRequest request)
 {
     return(_service.Get(request));
 }