public EmployeesServiceAssignment EmployeesService(int workOrderId, int userId, string userName) { var workOrderChildManpower = _context.WorkOrderChildManpowers.Where(x => x.WorkOrderId == workOrderId).ToList(); EmployeesServiceAssignment employeesServiceAssignment = new EmployeesServiceAssignment(); employeesServiceAssignment.WorkOrderChildManpower = workOrderChildManpower; return(employeesServiceAssignment); }
public void AddEmployeesServiceAssignment(int workOrderId, EmployeesServiceAssignment employeesServiceAssignment) { List <EmployeesServiceAssignment> EmployeesServiceAssignmentList = new List <EmployeesServiceAssignment>(); foreach (var item in employeesServiceAssignment.WorkOrderChildManpower) { if (item.IsChecked == true) { EmployeesServiceAssignmentList.Add(new EmployeesServiceAssignment() { WorkOrderId = workOrderId, EmployeeId = item.EmployeeId }); } } foreach (var item in EmployeesServiceAssignmentList) { _context.EmployeesServiceAssignments.Add(item); } _context.SaveChanges(); }