// Lookup Job public ActionResult GetJobListForAutocomplete(string term, long? accountid) { GetJobsInput getjobsinput = new GetJobsInput(); if (accountid.HasValue) { var jobList = _svcJob.GetJobs(getjobsinput).Jobs. Where(j => j.AccountId.Equals(accountid)) .Where(j => j.Description.ToUpper().Contains(term.ToUpper())) .Take(5) .Select(j => new { id = j.Id, label = j.Description }); return Json(jobList, JsonRequestBehavior.AllowGet); } else { var jobList = _svcJob.GetJobs(getjobsinput).Jobs. Where(j => j.Description.ToUpper().Contains(term.ToUpper())) .Take(5) .Select(j => new { id = j.Id, label = j.Description }); return Json(jobList, JsonRequestBehavior.AllowGet); } }
public GetJobsOutput GetJobs(GetJobsInput input) { //Called specific GetAllWithPeople method of task repository. var jobs = _jobRepository.GetAllWithUser(input.AssignedUserId, input.State, input.AccountId, input.Type); //Used AutoMapper to automatically convert List<Task> to List<TaskDto>. return new GetJobsOutput { Jobs = Mapper.Map<List<JobDto>>(jobs) }; }