예제 #1
0
        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.");
            }
        }
예제 #2
0
        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);
            }
        }