public async Task UpdateShowDoc(ShowDocEntity entity)
        {
            await LoadData();

            _data.RemoveAll(x => x.Id == entity.Id);
            _data.Add(entity);
            await _dataProvider.SaveChanges(_data);
        }
        public SwaggerParserV3_Tests()
        {
            _showdoc = new ShowDocEntity()
            {
                AppKey     = "5b2451ec0a8b49f5323645e6d50d9b29557907599",
                AppToken   = "170c09f45fe6e70642cc17c44ff9213f1222612682",
                ShowDocUrl = "https://www.showdoc.cc/server/api/item/updateByApi"
            };
            var str = File.ReadAllText(AppContext.BaseDirectory + "swaggerDocsV3.json", Encoding.UTF8);

            _documentCoreV3 = SwaggerParser.ParseString(str) as SwaggerDocumentCoreV3;
        }
        public SwaggerParserV2_Tests()
        {
            _showdoc = new ShowDocEntity()
            {
                AppKey     = "a338fb0d83c6f4b660bc2706b92e89451844587564",
                AppToken   = "e1511a84db06d25150377970f328e9f7572510835",
                ShowDocUrl = "https://www.showdoc.cc/server/api/item/updateByApi"
            };
            var str = File.ReadAllText(AppContext.BaseDirectory + "swaggerDocsV2.json", Encoding.UTF8);

            _document = SwaggerParser.ParseString(str) as SwaggerDocumentCoreV2;
        }
Example #4
0
        public static async Task <ShowDocResponse> UpdateByApi(ShowDocEntity entity, ShowDocRequest request)
        {
            var content = new FormUrlEncodedContent(new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("api_key", entity.AppKey),
                new KeyValuePair <string, string>("api_token", entity.AppToken),
                new KeyValuePair <string, string>("cat_name", request.CatName),
                new KeyValuePair <string, string>("page_title", request.PageTitle),
                new KeyValuePair <string, string>("page_content", request.PageContent),
                new KeyValuePair <string, string>("s_number", request.SNumber.ToString()),
            });

            var response = await HttpClient.PostAsync(entity.ShowDocUrl, content);

            return(JsonConvert.DeserializeObject <ShowDocResponse>(await response.Content.ReadAsStringAsync()));
        }
        public async Task <ShowDocEntity> AddShowDoc(ShowDocEntity entity)
        {
            await LoadData();

            if (!_data.Any())
            {
                entity.Id = 1;
            }
            else
            {
                entity.Id = _data.Max(x => x.Id) + 1;
            }

            _data.Add(entity);
            await _dataProvider.SaveChanges(_data);

            return(entity);
        }