public List <GetJobOffersView> GetAllJobOffers(string type) { var jobs = dbContext.jobOffers.OrderByDescending(o => o.Id).ToList(); var allOffers = new List <GetJobOffersView>(); if (type == "short") { foreach (var item in jobs) { GetJobOffersView getJob = new GetJobOffersView() { Id = item.Id, AplicationDetails = JobApplicationServices.Get20(item.AplicationDetails), AplicationRequirement = item.AplicationRequirement, Deadline = item.Deadline, NoOfApplicant = item.NoOfApplicant, Position = item.Position, Title = item.Title, UserId = item.UserId, Image = JobApplicationServices.ImageConvertToString(item.Image), DateCreated = item.DateCreated }; allOffers.Add(getJob); } } else { foreach (var item in jobs) { GetJobOffersView getJob = new GetJobOffersView() { Id = item.Id, AplicationDetails = item.AplicationDetails, AplicationRequirement = item.AplicationRequirement, Deadline = item.Deadline, NoOfApplicant = item.NoOfApplicant, Position = item.Position, Title = item.Title, UserId = item.UserId, Image = JobApplicationServices.ImageConvertToString(item.Image), DateCreated = item.DateCreated }; allOffers.Add(getJob); } } return(allOffers); }
//this method gets the specific job user clicks to display the whole details public GetJobOffersView GetAJobOffer(int id) { var jobs = dbContext.jobOffers.Where(j => j.Id == id).FirstOrDefault(); GetJobOffersView getJob = new GetJobOffersView() { Id = jobs.Id, AplicationDetails = JobApplicationServices.Get20(jobs.AplicationDetails), AplicationRequirement = jobs.AplicationRequirement, Deadline = jobs.Deadline, NoOfApplicant = jobs.NoOfApplicant, Position = jobs.Position, Title = jobs.Title, UserId = jobs.UserId, Image = JobApplicationServices.ImageConvertToString(jobs.Image), DateCreated = jobs.DateCreated }; return(getJob); }