Example #1
0
        public async Task HandleAsync(CreateUserCommand command)
        {
            var user = await _swizzerContext.Users.FirstOrDefaultAsync(x => x.Email == command.Email);

            if (user != null)
            {
                throw new SwizzerServerException(ErrorCode.InvalidParameter, $"{command.Email} already exist with ${user.Id}");
            }

            user = _swizzerMapper.MapTo <User>(command);

            user.Salt = _seciurityService.GetSalt();
            user.Hash = _seciurityService.GetHash(command.Password, user.Salt);

            await _swizzerContext.AddAsync(user);

            var dto = _swizzerMapper.MapTo <UserDto>(user);

            _cacheService.Set(dto);
        }
Example #2
0
 public bool AddToCache(string key, Value value)
 {
     return(service.Set(key, value));
 }