public void GetAllNextRegisteredActions_SingleClient_RegisteredActionsExists_ValidPlan() { var employee = new Employee(); DataContext.Employees.Add(employee); var client = new Client(); DataContext.Clients.Add(client); CreateClientEmployeePlanActionStructure(employee.Id, client.Id, true); var action1 = new RegisteredClientAction { PlannedStartDateTime = DateTime.Now.AddHours(-1), ClientId = client.Id, EmployeeId = employee.Id }; var action2 = new RegisteredClientAction { PlannedStartDateTime = DateTime.Now.AddHours(1), ClientId = client.Id, EmployeeId = employee.Id }; var action3 = new RegisteredClientAction { PlannedStartDateTime = DateTime.Now.AddHours(2), ClientId = client.Id, EmployeeId = employee.Id }; DataContext.RegisteredClientActions.AddRange(new[] { action1, action2, action3 }); DataContext.SaveChanges(); var result = _testedService.GetAllNextRegisteredActions(employee.Id); Assert.IsNull(result.FirstOrDefault(r => r.Id == action1.Id)); Assert.IsNull(result.FirstOrDefault(r => r.Id == action3.Id)); Assert.IsNotNull(result.FirstOrDefault(r => r.Id == action2.Id)); }
public ClientWithNextActionDTO[] GetAllClientsWithNextAction(Guid?employeeId = null) { var clientActions = _clientApiService.GetAllNextRegisteredActions(employeeId); var clients = _clientApiService.GetAgreedActionsLinkedClients(employeeId); var clientsWithNextAction = new List <ClientWithNextActionDTO>(); foreach (var client in clients) { var nextClientAction = clientActions.SingleOrDefault(ca => ca.ClientId == client.Id); var dto = new ClientWithNextActionDTO(); dto.ClientId = client.Id; dto.NextAction = nextClientAction != null?MapRegisteredActionToBasicDto(nextClientAction) : null; clientsWithNextAction.Add(dto); } return(clientsWithNextAction.ToArray()); }