Exemple #1
0
        public AddNewClientResponseDto AddNewClient(AddNewClientRequestDto addNewClientRequestDto)
        {
            if (_advertDbContext.Clients.Any(c => c.Login.Equals(addNewClientRequestDto.Login)))
            {
                throw new ObjectAlreadyInDatabaseException("Login already in database");
            }

            var client = _mapper.Map <Client>(addNewClientRequestDto);
            var salt   = _passwordService.GenerateSalt();

            client.Salt     = salt;
            client.Password = _passwordService.CreateSaltedPasswordHash(addNewClientRequestDto.Password, salt);

            _advertDbContext.Add((object)client);
            _advertDbContext.SaveChanges();

            return(_mapper.Map <AddNewClientResponseDto>(client));
        }
 public IActionResult AddNewClient(AddNewClientRequestDto addNewClientRequestDto)
 {
     return(Created("", _clientDbService.AddNewClient(addNewClientRequestDto)));
 }