-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59aa776
commit ad558c0
Showing
550 changed files
with
178,757 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
BtkAkademi.GatewaySolution/BtkAkademi.GatewaySolution.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
BtkAkademi.Services.CouponAPI/BtkAkademi.Services.CouponAPI.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
36
BtkAkademi.Services.CouponAPI/Controllers/CouponAPIController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.