Example #1
0
        public async Task <IActionResult> GetOrders()
        {
            var bsn      = _jwtTokenProvider.GetBsnFromClaims(HttpContext.User);
            var url      = string.Format(GetRequest, _baseUri);
            var response = await _serviceClient.GetAsync(url);

            var result = await response.Content.ReadAsStringAsync();

            var allRequest = JsonConvert.DeserializeObject <List <Request> >(result);

            //Filter request on submitter (TODO: When the conduction API fixes the filtering on the API side, this wont be necessary)
            var requestFromBsn = new List <Request>();

            foreach (var request in allRequest)
            {
                if (request.submitters.Length == 1 && request.submitters.First().person == bsn)
                {
                    //Add the correct data for the request(based on the requestType?)
                    await AddRequestDataFromType(request);

                    requestFromBsn.Add(request);
                }
            }

            //Order request on create date. Last one on top
            var orderedRequest = requestFromBsn.OrderByDescending(r => r.date_created).ToList();

            return(Json(orderedRequest));
        }
Example #2
0
        internal async Task <Persoon> GetPersonFromApi(ClaimsPrincipal user)
        {
            var bsn    = _jwtTokenProvider.GetBsnFromClaims(user);
            var url    = string.Format(UrlGetByBsn, _baseUri, bsn);
            var result = await CallApi(url);

            var person = JsonConvert.DeserializeObject <Persoon>(result);

            return(person);
        }
Example #3
0
        private async Task <IActionResult> CallRequestApiAsync(Order order)
        {
            var bsn           = _jwtTokenProvider.GetBsnFromClaims(HttpContext.User);
            var requestData   = CreateRequestData(order, bsn);
            var stringContent = new StringContent(JsonConvert.SerializeObject(requestData), Encoding.UTF8, "application/json");
            var response      = await _serviceClient.PostAsync(string.Format(PostRequest, _baseUri), stringContent);

            var result = await response.Content.ReadAsStringAsync();

            if (response.StatusCode == HttpStatusCode.Created)
            {
                ////Retrieve the "request url" from the response.
                //dynamic resultDynamic = JsonConvert.DeserializeObject<dynamic>(result);
                //var self = resultDynamic._links.self;
                //return Json(self);
                return(Ok());
            }

            return(BadRequest(Json(result)));
        }