Example #1
0
        public Task <bool> DeleteFile(int fileId, int contentId, [FromBody] FileIdDto item2)
        {
            Console.WriteLine("token" + item2.TokenString);

            var FilesDetailsDelete = _mapper.Map <UserFileDetails>(item2);

            AuthenticationTokenClass AuthenticationTokenClassObjRef = new AuthenticationTokenClass();

            TokenDto tokendto         = new TokenDto();
            string   tokenref         = AuthenticationTokenClassObjRef.AuthenticationToken(tokendto).Result;
            object   jsonObject       = JsonConvert.DeserializeObject(tokenref);
            var      ParsedJsonObject = JObject.Parse(tokenref);
            string   tokenserver      = ParsedJsonObject["tokenstored"].ToString();
            dynamic  dynJson          = JsonConvert.DeserializeObject(tokenserver);

            foreach (var item in dynJson)
            {
                String tokenstored = item.tokenstored;

                if (item2.TokenString == tokenstored)
                {
                    try
                    {
                        return(_service.DeleteFile(fileId, contentId, FilesDetailsDelete));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }

            return(null);
        }
Example #2
0
        public async void PutByFileId(int fileId, [FromBody] FileIdDto item)
        {
            Console.WriteLine("Inside contentdetails gateway update");
            GatewayTokenClass gatewayTokenClassObjRef = new GatewayTokenClass();
            GatewayTokenDto   tokendtoRef             = new GatewayTokenDto();
            string            tokenref   = gatewayTokenClassObjRef.GatewayToken(tokendtoRef).Result;
            object            jsonObject = JsonConvert.DeserializeObject(tokenref);
            var    obj3  = JObject.Parse(tokenref);
            string token = obj3["token"].ToString();

            Console.WriteLine("token" + token);
            //passing token from gateway to respective microservice
            item.TokenString = token;
            //Microservice request
            var client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            AppConfig api        = new AppConfig();
            var       stringTask = await client.PutAsync(api.filesDetailsUrl + "api/FilesDetails" + "/" + fileId, new StringContent(JsonConvert.SerializeObject(item), Encoding.UTF8, "application/json"));

            var msg = stringTask.Content.ReadAsStringAsync().Result;

            Console.WriteLine("Result is" + msg);
        }