public AddRepairViewModel GetAllRepairDetailsForAdd() { AddRepairViewModel addRepairViewModel = new AddRepairViewModel(); var allCustomers = this.Context.Customers.ToList(); var allEmployees = this.Context.Employees.ToList(); var allItems = this.Context.Items.ToList(); foreach (Customer customer in allCustomers) { CustomerRepairViewModel customerRepairViewModel = Mapper.Map <CustomerRepairViewModel>(customer); addRepairViewModel.Customers.Add(customerRepairViewModel); } foreach (Employee employee in allEmployees) { EmployeeRepairViewModel employeeRepairView = Mapper.Map <EmployeeRepairViewModel>(employee); addRepairViewModel.Employees.Add(employeeRepairView); } foreach (Item item in allItems) { ItemRepairViewModel itemRepairViewModel = Mapper.Map <ItemRepairViewModel>(item); addRepairViewModel.Items.Add(itemRepairViewModel); } return(addRepairViewModel); }
public EditRepairViewModel GetEditedRepair(int id) { Repair repair = this.Context.Repairs.Find(id); var allEmployees = this.Context.Employees.ToList(); EditRepairViewModel viewModel = Mapper.Map <EditRepairViewModel>(repair); foreach (Employee employee in allEmployees) { EmployeeRepairViewModel employeeRepairView = Mapper.Map <EmployeeRepairViewModel>(employee); viewModel.Employees.Add(employeeRepairView); } return(viewModel); }