Skip to content

Commit

Permalink
Brand listesi dönüyor
Browse files Browse the repository at this point in the history
  • Loading branch information
Murat OĞUZ committed Aug 16, 2020
1 parent 4efe301 commit 5803a42
Show file tree
Hide file tree
Showing 91 changed files with 1,421 additions and 183 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

using System.Net.Http;
using System.Net.Http.Headers;
using NetCore_Trendyol_Entegrasyon.Models.Product;
using System.Text.Json;

namespace NetCore_Trendyol_Entegrasyon.Controllers.Product
{
[ApiController]
[Route("[controller]")]
public class BrandsController : ControllerBase
{




/// <summary>
/// Get BrandListFrom Trendyol
/// </summary>
/// <returns></returns>
/// <remarks>
/// Sample request:
///
/// GET /Brands
///
/// </remarks>
/// <returns>List of Brands</returns>
[HttpGet]
public async Task<List<BrandsModel>> GetBrands()
{
var brandList = new List<BrandsModel>();
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://api.trendyol.com/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.GetAsync("sapigw/brands");
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
brandList = JsonSerializer.Deserialize<BrandsList>(content).brands;
}

}

return brandList;
}

}

}

This file was deleted.

22 changes: 22 additions & 0 deletions NetCore-Trendyol-Entegrasyon/Models/Product/BrandsModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System.Collections.Generic;

namespace NetCore_Trendyol_Entegrasyon.Models.Product
{

public class BrandsList{

public List<BrandsModel> brands { get; set; }

}
public class BrandsModel{


public int id { get; set; }
public string name { get; set; }

}

}
26 changes: 15 additions & 11 deletions NetCore-Trendyol-Entegrasyon/NetCore-Trendyol-Entegrasyon.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>NetCore_Trendyol_Entegrasyon</RootNamespace>
</PropertyGroup>

<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>NetCore_Trendyol_Entegrasyon</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.7" />
Expand All @@ -21,7 +25,7 @@
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
<PackageReference Include="NpgSql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.0" />
</ItemGroup>


</Project>
</ItemGroup>


</Project>
52 changes: 32 additions & 20 deletions NetCore-Trendyol-Entegrasyon/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
using Swashbuckle.AspNetCore.Swagger;
using Microsoft.OpenApi.Models;

using System.IO;
using System.Reflection;

namespace NetCore_Trendyol_Entegrasyon
{
public class Startup
Expand Down Expand Up @@ -50,37 +53,46 @@ public void ConfigureServices(IServiceCollection services)
Name = "Use under LICX",
// Url = new Uri("https://example.com/license"),
}
});


});
// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);

});



}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", ".NetCore Trendyol Entegrasyon");
});
c.SwaggerEndpoint("/swagger/v1/swagger.json", ".NetCore Trendyol Entegrasyon");
});

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();
app.UseHttpsRedirection();

app.UseRouting();
app.UseRouting();

app.UseAuthorization();
app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});


}
}
}
}
15 changes: 0 additions & 15 deletions NetCore-Trendyol-Entegrasyon/WeatherForecast.cs

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 5803a42

Please sign in to comment.