Exemplo n.º 1
0
        public async Task <List <List <int> > > GetGroupActivityCredentials(int groupId, SupportActivities supportActivitiy)
        {
            var getGroupActivityCredentialsRequest = new GetGroupActivityCredentialsRequest()
            {
                GroupId             = groupId,
                SupportActivityType = new SupportActivityType()
                {
                    SupportActivity = supportActivitiy
                },
            };

            string              json     = JsonConvert.SerializeObject(getGroupActivityCredentialsRequest);
            StringContent       data     = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await Client.PostAsync("/api/GetGroupActivityCredentials", data);

            string str = await response.Content.ReadAsStringAsync();

            var deserializedResponse = JsonConvert.DeserializeObject <ResponseWrapper <GetGroupActivityCredentialsResponse, GroupServiceErrorCode> >(str);

            if (deserializedResponse.HasContent && deserializedResponse.IsSuccessful)
            {
                return(deserializedResponse.Content.CredentialSets);
            }
            return(null);
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
            [RequestBodyType(typeof(GetGroupActivityCredentialsRequest), "Get Group Activity Credentials")] GetGroupActivityCredentialsRequest req,
            CancellationToken cancellationToken)
        {
            try
            {
                GetGroupActivityCredentialsResponse response = await _mediator.Send(req, cancellationToken);

                return(new OkObjectResult(ResponseWrapper <GetGroupActivityCredentialsResponse, GroupServiceErrorCode> .CreateSuccessfulResponse(response)));
            }
            catch (Exception ex)
            {
                _logger.LogErrorAndNotifyNewRelic($"Unhandled error in GetGroupActivityCredentials", ex);
                return(new ObjectResult(ResponseWrapper <GetGroupActivityCredentialsResponse, GroupServiceErrorCode> .CreateUnsuccessfulResponse(GroupServiceErrorCode.InternalServerError, "Internal Error"))
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }
Exemplo n.º 3
0
        public async Task <GetGroupActivityCredentialsResponse> GetGroupActivityCredentials(GetGroupActivityCredentialsRequest request)
        {
            string path         = $"/api/GetGroupActivityCredentials";
            string absolutePath = $"{path}";
            var    jsonContent  = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            using (HttpResponseMessage response = await _httpClientWrapper.PostAsync(HttpClientConfigName.GroupService, absolutePath, jsonContent, CancellationToken.None).ConfigureAwait(false))
            {
                string jsonResponse = await response.Content.ReadAsStringAsync();

                var getJobsResponse = JsonConvert.DeserializeObject <ResponseWrapper <GetGroupActivityCredentialsResponse, GroupServiceErrorCode> >(jsonResponse);
                if (getJobsResponse.HasContent && getJobsResponse.IsSuccessful)
                {
                    return(getJobsResponse.Content);
                }
                return(null);
            }
        }