private async Task CheckLogin(List <ValidationFailure> list, SaveEmployee.SaveEmployeeCommand request) { var exists = await _employeeService.IsExists(request.Login).ConfigureAwait(false); if (exists && request.IsCreateCommand) { list.Add($"Login '{request.Login}' already exists."); } if (!exists && !request.IsCreateCommand) { list.Add($"Login '{request.Login}' not found."); } }
public async Task Validate(List <ValidationFailure> list, SaveEmployee.SaveEmployeeCommand request) { list.NotNullOrEmpty("Login", request.Login); list.NotNullOrEmpty("FirstName", request.FirstName); list.NotNullOrEmpty("LastName", request.LastName); var tasks = new List <Task> { CheckLogin(list, request), CheckManager(list, request), CheckAttributes(list, request) }; foreach (var task in tasks) { await task.ConfigureAwait(false); } }