Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
HakanBayazitHabes committed Aug 15, 2023
1 parent 59aa776 commit ad558c0
Show file tree
Hide file tree
Showing 550 changed files with 178,757 additions and 0 deletions.
21 changes: 21 additions & 0 deletions BtkAkademi.GatewaySolution/BtkAkademi.GatewaySolution.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="IdentityModel" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.0" />
<PackageReference Include="Ocelot" Version="17.0.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>

</Project>
37 changes: 37 additions & 0 deletions BtkAkademi.GatewaySolution/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.IdentityModel.Tokens;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
builder.Services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options =>
{

options.Authority = "https://localhost:44365/";
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false
};

});

builder.Services.AddOcelot();
var app = builder.Build();


app.UseHttpsRedirection();

app.UseAuthorization();
app.UseAuthentication();
app.MapControllers();

await app.UseOcelot();

app.Run();


app.Run();
30 changes: 30 additions & 0 deletions BtkAkademi.GatewaySolution/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:37209",
"sslPort": 44355
}
},
"profiles": {
"IIS Express": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5050/"
},
"BtkAkademi.GatewaySolution": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"hotReloadProfile": "aspnetcore",
"dotnetRunMessages": "true",
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
8 changes: 8 additions & 0 deletions BtkAkademi.GatewaySolution/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
209 changes: 209 additions & 0 deletions BtkAkademi.GatewaySolution/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
//"ProductAPI": "https://localhost:44390",

//"ShoppingCartAPI": "https://localhost:44338",
//"CouponAPI": "https://localhost:44393",
,

"Routes": [
{
"DownstreamPathTemplate": "/api/products",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44390
}
],
"UpstreamPathTemplate": "/api/products",
"UpstreamHttpMethod": [ "GET" ]
},
{
"DownstreamPathTemplate": "/api/products/{id}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44390
}
],
"UpstreamPathTemplate": "/api/products/{id}",
"UpstreamHttpMethod": [ "GET" ]
},
{
"DownstreamPathTemplate": "/api/products",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44390
}
],
"UpstreamPathTemplate": "/api/products",
"UpstreamHttpMethod": [ "POST", "PUT" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
{
"DownstreamPathTemplate": "/api/products/{id}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44390
}
],
"UpstreamPathTemplate": "/api/products/{id}",
"UpstreamHttpMethod": [ "DELETE" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
//cart settings

{
"DownstreamPathTemplate": "/api/cart/",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44338
}
],
"UpstreamPathTemplate": "/api/cart/",
"UpstreamHttpMethod": [ "POST" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
{
"DownstreamPathTemplate": "/api/cart/ApplyCoupon",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44338
}
],
"UpstreamPathTemplate": "/api/cart/ApplyCoupon",
"UpstreamHttpMethod": [ "POST" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
{
"DownstreamPathTemplate": "/api/cartc/",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44338
}
],
"UpstreamPathTemplate": "/api/cartc/",
"UpstreamHttpMethod": [ "POST" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
{
"DownstreamPathTemplate": "/api/cart/GetCart/{userId}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44338
}
],
"UpstreamPathTemplate": "/api/cart/GetCart/{userId}",
"UpstreamHttpMethod": [ "GET" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
{
"DownstreamPathTemplate": "/api/cart/RemoveCoupon",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44338
}
],
"UpstreamPathTemplate": "/api/cart/RemoveCoupon",
"UpstreamHttpMethod": [ "POST" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
{
"DownstreamPathTemplate": "/api/cart/RemoveCart",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44338
}
],
"UpstreamPathTemplate": "/api/cart/RemoveCart",
"UpstreamHttpMethod": [ "POST" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
{
"DownstreamPathTemplate": "/api/cart/UpdateCart",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44338
}
],
"UpstreamPathTemplate": "/api/cart/UpdateCart",
"UpstreamHttpMethod": [ "POST" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
},
//coupon
{
"DownstreamPathTemplate": "/api/coupon/{couponCode}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44393
}
],
"UpstreamPathTemplate": "/api/coupon/{couponCode}",
"UpstreamHttpMethod": [ "GET" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Bearer",
"AllowedScopes": [ "btkakademi" ]
}
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:5050"
}

}
23 changes: 23 additions & 0 deletions BtkAkademi.Services.CouponAPI/BtkAkademi.Services.CouponAPI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.1.4" />
</ItemGroup>

</Project>
36 changes: 36 additions & 0 deletions BtkAkademi.Services.CouponAPI/Controllers/CouponAPIController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using BtkAkademi.Services.CouponAPI.Models.Dto;
using BtkAkademi.Services.CouponAPI.Repository;
using Microsoft.AspNetCore.Mvc;

namespace BtkAkademi.Services.CouponAPI.Controllers
{
[ApiController]
[Route("api/coupon")]
public class CouponAPIController : Controller
{
private readonly ICouponRepository _couponRepository;
protected ResponseDto _response;

public CouponAPIController(ICouponRepository couponRepository)
{
_couponRepository = couponRepository;
this._response = new ResponseDto();
}

[HttpGet("{code}")]
public async Task<object> GetDiscountForCode(string code)
{
try
{
var coupon = await _couponRepository.GetCouponByCode(code);
_response.Result = coupon;
}
catch (Exception ex)
{
_response.IsSuccess = false;
_response.ErrorMessages = new List<string>() { ex.ToString() };
}
return _response;
}
}
}
Loading

0 comments on commit ad558c0

Please sign in to comment.