Пример #1
0
        public async Task AddAsync(ExpertRequest request)
        {
            var user = await _userRepository.GetByAddressAsync(request.Address);

            if (user == null)
            {
                throw new AppErrorException(ErrorCode.UserNotFound);
            }

            user.SecondName = request.SecondName;
            user.FirstName  = request.FirstName;
            user.Email      = request.Email;
            user.About      = request.About;

            await _userRepository.AddRoleAsync(user.Id, RoleType.Expert);

            await _userRepository.SaveChangesAsync();

            var expert = new Expert(user.Id, true);

            expert.SetAreas(request.Areas);

            _expertRepository.Add(expert);

            await _expertRepository.SaveChangesAsync();
        }