public IActionResult All(AllFreelancersViewModel viewModel) { viewModel.Freelancers = this.usersService.GetAll <FreelancerViewModel>(); viewModel.Freelancers.Select(f => { f.Categories = f.Categories.Take(3); f.EncryptedId = this.protector.Protect(f.Id); return(f); }).ToList(); viewModel.TopFreelancers = this.usersService.GetTop <FreelancerViewModel>() .Select(f => { f.Categories = f.Categories.Take(3); f.EncryptedId = this.protector.Protect(f.Id); return(f); }).ToList(); viewModel.RecentlyJoined = this.usersService.GetRecent <FreelancerViewModel>().Select(f => { f.Categories = f.Categories.Take(3); f.EncryptedId = this.protector.Protect(f.Id); return(f); }).ToList(); return(this.View(viewModel)); }
public ActionResult <AllFreelancersViewModel> AllOrderedByRating() { var freelancers = this.usersService.GetAll <FreelancerViewModel>(); var viewModel = new AllFreelancersViewModel(); viewModel.Freelancers = freelancers.OrderByDescending(f => f.Stars).ToList(); viewModel.Freelancers.Select(f => { f.Categories = f.Categories.Take(3); f.EncryptedId = this.protector.Protect(f.Id); return(f); }).ToList(); return(viewModel); }