Exemplo n.º 1
0
        public void AddDirection(DirectionClient directionClient)
        {
            DBconn.Open();

            var sqlAddDirection = new NpgsqlCommand(
                "INSERT INTO directions_clients (direction, client_email) " +
                "VALUES (@p1, @p2)", DBconn
                );

            sqlAddDirection.Parameters.AddWithValue("p1", directionClient.direction);
            sqlAddDirection.Parameters.AddWithValue("p2", directionClient.client_email);
            sqlAddDirection.ExecuteNonQuery();

            DBconn.Close();
        }
Exemplo n.º 2
0
        public ActionResult <ClientDto> CreateClient(ClientDto clientDto)
        {
            var clientModel = _mapper.Map <Client>(clientDto);

            _repository.AddClient(clientModel);

            var directionClientModel = new DirectionClient();

            directionClientModel.client_email = clientDto.email;
            directionClientModel.direction    = clientDto.direction;
            _repository.AddDirection(directionClientModel);

            var newClientDto = _mapper.Map <ClientDto>(clientModel);

            return(CreatedAtRoute(nameof(GetClientByEmail), new { email = newClientDto.email },
                                  newClientDto));
        }