Esempio n. 1
0
        public async Task AddUserAsync(User user)
        {
            var userEntity = MapToEntity <UserEntity, User>(user, (obj, entity) =>
            {
                entity.Password = string.IsNullOrWhiteSpace(entity.Password) ? null : _cryptographyService.Cryptograph(entity.Password);
                entity.Doctor   = null;
            });

            var documentId = await _repository.AddAsync(userEntity);

            if (user.Doctor != default(Doctor))
            {
                var doctorEntity = MapToEntity <DoctorEntity, Doctor>(user.Doctor);

                await _repository.AddNestedAsync(doctorEntity, nameof(Doctor), documentId);
            }
        }