public HttpResponseMessage GetJobsByRecruiter(string id = null) { if (User.Identity.IsAuthenticated) { id = User.Identity.GetUserId(); } else if (string.IsNullOrEmpty(id)) { return(Request.CreateResponse <object>(HttpStatusCode.OK, new string[0])); } var recruiter = JobsCacheManager.ListRecruiterJobPosts.FirstOrDefault(r => r.Id == id); if (recruiter == null) { var jobs = db.JobPosts.Where(j => !(j.IsDeleted ?? false) && j.CreatedBy == id).ToList().Select(j => new JobPostViewModel(j)).OrderByDescending(j => j.dateCreated).ToList(); foreach (var item in jobs) { item.shortDescription = Helpers.ShortenDescription(item.jobDescription); item.jobDescription = null; } recruiter = new JobsCacheManager.RecruiterJobPosts { Id = id, Jobs = jobs }; JobsCacheManager.ListRecruiterJobPosts.Enqueue(recruiter); } return(Request.CreateResponse <IEnumerable <JobPostViewModel> >(HttpStatusCode.OK, recruiter.Jobs)); }
public HttpResponseMessage GetJobsByRecruiter(string id=null) { if (User.Identity.IsAuthenticated) id = User.Identity.GetUserId(); else if (string.IsNullOrEmpty(id)) return Request.CreateResponse<object>(HttpStatusCode.OK, new string[0]); var recruiter = JobsCacheManager.ListRecruiterJobPosts.FirstOrDefault(r => r.Id == id); if (recruiter == null) { var jobs = db.JobPosts.Where(j => !(j.IsDeleted ?? false) && j.CreatedBy == id).ToList().Select(j => new JobPostViewModel(j)).OrderByDescending(j => j.dateCreated).ToList(); foreach (var item in jobs) { item.shortDescription = Helpers.ShortenDescription(item.jobDescription); item.jobDescription = null; } recruiter = new JobsCacheManager.RecruiterJobPosts { Id = id, Jobs = jobs }; JobsCacheManager.ListRecruiterJobPosts.Enqueue(recruiter); } return Request.CreateResponse<IEnumerable<JobPostViewModel>>(HttpStatusCode.OK, recruiter.Jobs); }