public CreateAuthKeyResponse CreateAuthKey(CreateAuthKeyRequest request)
        {
            CreateAuthKeyResponse response = new CreateAuthKeyResponse
            {
                Success = true,
                Error   = ""
            };

            User_Keys key = Mapper.Map <User_Keys>(request.AuthKey);

            User_Keys DbKey = db.User_Keys.FirstOrDefault(k => k.UserNr == key.UserNr && k.ExchangeType == key.ExchangeType);

            if (DbKey != null)
            {
                response.Success = false;
                response.Error   = "A key for that exchange already exists";
                return(response);
            }

            try
            {
                db.User_Keys.Add(key);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                _logger.ErrorFormat($"error happend error: {e.Message} stacktrace: {e.StackTrace}");
                response.Success = false;
                response.Error   = "An error occured in user creation please check logs for more details";
            }

            return(response);
        }
Exemplo n.º 2
0
        public CreateAuthKeyResponse CreateAuthKey(CreateAuthKeyRequest request)
        {
            RestRequest restRequest = new RestRequest("Account/CreateAuthKey", Method.POST);

            restRequest.AddJsonBody(request);

            CreateAuthKeyResponse response = _client.Execute <CreateAuthKeyResponse>(restRequest).Data;

            return(response);
        }
Exemplo n.º 3
0
        public CreateAuthKeyResponse CreateAuthKey(CreateAuthKeyData data)
        {
            CreateAuthKeyRequest request = new CreateAuthKeyRequest
            {
                AuthKey = new AuthKey
                {
                    UserNr       = GetUserAuthenticationData().UserNr,
                    ExchangeType = data.ExchangeType,
                    KeyValue     = data.KeyValue,
                    SecretValue  = data.SecretValue
                }
            };

            CreateAuthKeyResponse response = _client.CreateAuthKey(request);

            return(response);
        }
Exemplo n.º 4
0
        public CreateAuthKeyResponse CreateAuthKey([FromBody] CreateAuthKeyRequest request)
        {
            CreateAuthKeyResponse response = _accountFacade.CreateAuthKey(request);

            return(response);
        }