public List <EmploymentIndexViewModel> GetAllEmployment() { var allEmployemts = _db.Employments.Include(e => e.Student) .Include(e => e.Company).Include(e => e.Salary).ToList(); var employmentDetails = new List <EmploymentIndexViewModel>(); foreach (var employment in allEmployemts) { EmploymentIndexViewModel employmentIndex = new EmploymentIndexViewModel { Company = employment.Company.Name, EndDate = employment.EndDate, Id = employment.EmploymentId, StartDate = employment.StartDate, StudentName = employment.Student.Name, }; if (employment.Salary != null) { employmentIndex.Salary = employment.Salary.Amount; } employmentDetails.Add(employmentIndex); } return(employmentDetails); }
public async Task <IActionResult> Index(int personId) { var emps = await _proxy.GetPersonEmployments(personId); var vms = Mapper.Map <IEnumerable <EmploymentViewModel> >(emps); var model = new EmploymentIndexViewModel { Items = vms, PersonId = personId }; return(PartialView("_EmploymentsTable", model)); }
public async Task <IActionResult> GetEmployments(int personId) { var emps = await _proxy.GetPersonEmployments(personId); var vms = Mapper.Map <IEnumerable <EmploymentViewModel> >(emps); var model = new EmploymentIndexViewModel { ModelPurpose = ViewModelPurpose.Index, Items = vms }; return(View("_EmploymentsTable", model)); }