Add project files.
This commit is contained in:
25
FaKrosnoApi/Controllers/CustomerOrdersController.cs
Normal file
25
FaKrosnoApi/Controllers/CustomerOrdersController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
using SytelineSaAppEfDataModel.Services;
|
||||
|
||||
namespace FaKrosnoApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class CustomerOrdersController(ICustomerOrderService service) : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<CustomerOrderDto>>> GetAll()
|
||||
{
|
||||
IEnumerable<CustomerOrderDto?> ediCustomerOrders = await service.GetAll();
|
||||
return Ok(ediCustomerOrders);
|
||||
}
|
||||
|
||||
[HttpGet("by-order-number")]
|
||||
public async Task<ActionResult<CustomerOrderDto?>> GetByCustomerOrderNumber([FromQuery] string customerOrderNumber)
|
||||
{
|
||||
CustomerOrderDto? scheduleOrder = await service.GetByOrderNumber(customerOrderNumber);
|
||||
return scheduleOrder != null ? Ok(scheduleOrder) : NotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
39
FaKrosnoApi/Controllers/EdiCustomerOrdersController.cs
Normal file
39
FaKrosnoApi/Controllers/EdiCustomerOrdersController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
using SytelineSaAppEfDataModel.Services;
|
||||
|
||||
namespace FaKrosnoApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class EdiCustomerOrdersController(IEdiCustomerOrderService service) : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<EdiCustomerOrderDto>>> GetAll()
|
||||
{
|
||||
IEnumerable<EdiCustomerOrderDto?> ediCustomerOrders = await service.GetAll();
|
||||
return Ok(ediCustomerOrders);
|
||||
}
|
||||
|
||||
[HttpGet("by-date")]
|
||||
public async Task<ActionResult<IEnumerable<EdiCustomerOrderDto>>> GetByDate([FromQuery] DateTime date)
|
||||
{
|
||||
IEnumerable<EdiCustomerOrderDto?> scheduleOrders = await service.GetByDate(date);
|
||||
return Ok(scheduleOrders);
|
||||
}
|
||||
|
||||
[HttpGet("by-order-number")]
|
||||
public async Task<ActionResult<EdiCustomerOrderDto>> GetByCustomerOrderNumber([FromQuery] string customerOrderNumber)
|
||||
{
|
||||
EdiCustomerOrderDto? scheduleOrder = await service.GetByOrderNumber(customerOrderNumber);
|
||||
return scheduleOrder != null ? Ok(scheduleOrder) : NotFound();
|
||||
}
|
||||
|
||||
[HttpPost("send-to-syteline")]
|
||||
public async Task<ActionResult<int>> SendOrderToSyteline([FromQuery] string customerOrderNumber)
|
||||
{
|
||||
int result = await service.SendOrderToSyteline(customerOrderNumber);
|
||||
return result > 0 ? Ok() : BadRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
25
FaKrosnoApi/Controllers/ErrorLogController.cs
Normal file
25
FaKrosnoApi/Controllers/ErrorLogController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
using SytelineSaAppEfDataModel.Services;
|
||||
|
||||
namespace FaKrosnoApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ErrorLogController(IErrorLogService service) : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ErrorLogDto>>> GetAll()
|
||||
{
|
||||
IEnumerable<ErrorLogDto?> errorLogs = await service.GetAll();
|
||||
return Ok(errorLogs);
|
||||
}
|
||||
|
||||
[HttpGet("by-order-number")]
|
||||
public async Task<ActionResult<IEnumerable<ErrorLogDto>>> GetByCustomerOrderNumber([FromQuery] string customerOrderNumber)
|
||||
{
|
||||
var errorLogs = await service.GetByOrderNumber(customerOrderNumber);
|
||||
return errorLogs.Any() ? Ok(errorLogs) : NotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
FaKrosnoApi/Controllers/ScheduleOrderDetailsController.cs
Normal file
18
FaKrosnoApi/Controllers/ScheduleOrderDetailsController.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using FaKrosnoEfDataModel.Dtos;
|
||||
using FaKrosnoEfDataModel.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace FaKrosnoApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ScheduleOrderDetailsController(IScheduleOrderDetailsService service) : Controller
|
||||
{
|
||||
[HttpGet("order/{scheduleOrderId:int}")]
|
||||
public async Task<ActionResult<IEnumerable<ScheduleOrderDto>>> GetByScheduleOrderId(int scheduleOrderId)
|
||||
{
|
||||
IEnumerable<ScheduleOrderDetailDto>? scheduleOrderDetails = await service.GetScheduleOrderDetailsAsync(scheduleOrderId);
|
||||
return Ok(scheduleOrderDetails);
|
||||
}
|
||||
}
|
||||
}
|
||||
50
FaKrosnoApi/Controllers/ScheduleOrdersController.cs
Normal file
50
FaKrosnoApi/Controllers/ScheduleOrdersController.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using AutoMapper;
|
||||
using FaKrosnoEfDataModel;
|
||||
using FaKrosnoEfDataModel.Dtos;
|
||||
using FaKrosnoEfDataModel.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace FaKrosnoApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
//[Authorize]
|
||||
public class ScheduleOrdersController(IScheduleOrderService service) : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ScheduleOrderDto>>> GetAll()
|
||||
{
|
||||
IEnumerable<ScheduleOrderDto?> scheduleOrders = await service.GetEntities();
|
||||
return Ok(scheduleOrders);
|
||||
}
|
||||
|
||||
[HttpGet("by-date")]
|
||||
public async Task<ActionResult<IEnumerable<ScheduleOrderDto>>> GetByDate([FromQuery] DateTime date)
|
||||
{
|
||||
IEnumerable<ScheduleOrderDto?> scheduleOrders = await service.GetEntitiesByLastUpdateDate(date);
|
||||
return Ok(scheduleOrders);
|
||||
}
|
||||
|
||||
[HttpGet("{id:int}")]
|
||||
public async Task<ActionResult<ScheduleOrderDto>> GetById(int id)
|
||||
{
|
||||
ScheduleOrderDto? scheduleOrder = await service.GetById(id);
|
||||
return scheduleOrder != null ? Ok(scheduleOrder) : NotFound();
|
||||
}
|
||||
|
||||
[HttpGet("recipient/{recipientId:int}")]
|
||||
public async Task<ActionResult<IEnumerable<ScheduleOrderDto>>> GetByRecipientId(int recipientId)
|
||||
{
|
||||
IEnumerable<ScheduleOrderDto?> scheduleOrders = await service.GetByRecipientId(recipientId);
|
||||
return Ok(scheduleOrders);
|
||||
}
|
||||
|
||||
[HttpGet("recipient/{recipientId:int}/date")]
|
||||
public async Task<ActionResult<IEnumerable<ScheduleOrderDto>>> GetByRecipientAndLastUpdateDate(int recipientId, [FromQuery] DateTime date)
|
||||
{
|
||||
IEnumerable<ScheduleOrderDto?> scheduleOrders = await service.GetByRecipientAndLastUpdateDate(recipientId, date);
|
||||
return Ok(scheduleOrders);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
FaKrosnoApi/FaKrosnoApi.csproj
Normal file
26
FaKrosnoApi/FaKrosnoApi.csproj
Normal file
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
|
||||
<PackageReference Include="NSwag.AspNetCore" Version="14.2.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FaKrosnoEfDataModel\FaKrosnoEfDataModel.csproj" />
|
||||
<ProjectReference Include="..\SytelineSaAppEfDataModel\SytelineSaAppEfDataModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
7
FaKrosnoApi/FaKrosnoApi.http
Normal file
7
FaKrosnoApi/FaKrosnoApi.http
Normal file
@@ -0,0 +1,7 @@
|
||||
@FaKrosnoApi_HostAddress = http://localhost:5152
|
||||
|
||||
### Access Swagger UI
|
||||
GET {{FaKrosnoApi_HostAddress}}/swagger/index.html
|
||||
Accept: text/html
|
||||
|
||||
###
|
||||
73
FaKrosnoApi/Program.cs
Normal file
73
FaKrosnoApi/Program.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Text;
|
||||
using FaKrosnoEfDataModel;
|
||||
using FaKrosnoEfDataModel.Services;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using SytelineSaAppEfDataModel;
|
||||
using SytelineSaAppEfDataModel.Services;
|
||||
using FaKrosnoMappingProfile = FaKrosnoEfDataModel.MappingProfile;
|
||||
using SytelineSaAppMappingProfile = SytelineSaAppEfDataModel.MappingProfile;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddDbContext<FaKrosnoDbContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("FaKrosnoConnection")));
|
||||
builder.Services.AddDbContext<SytelineSaAppDbContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("SytelineSaAppConnection")));
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddOpenApiDocument(config =>
|
||||
{
|
||||
config.Title = "FaKrosnoApi";
|
||||
config.Version = "v1";
|
||||
});
|
||||
|
||||
// Configure AutoMapper
|
||||
builder.Services.AddAutoMapper(typeof(FaKrosnoMappingProfile), typeof(SytelineSaAppMappingProfile));
|
||||
|
||||
// Configure JWT Authentication
|
||||
builder.Services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
}).AddJwtBearer(options =>
|
||||
{
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidIssuer = builder.Configuration["Jwt:Issuer"],
|
||||
ValidAudience = builder.Configuration["Jwt:Audience"],
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"]))
|
||||
};
|
||||
});
|
||||
|
||||
builder.Services.AddScoped<IScheduleOrderService, ScheduleOrderService>();
|
||||
builder.Services.AddScoped<IScheduleOrderDetailsService, ScheduleOrderDetailsService>();
|
||||
builder.Services.AddScoped<IEdiCustomerOrderService, EdiCustomerOrderService>();
|
||||
builder.Services.AddScoped<IErrorLogService, ErrorLogService>();
|
||||
builder.Services.AddScoped<ICustomerOrderService, CustomerOrderService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
//if (app.Environment.IsDevelopment())
|
||||
//{
|
||||
app.UseOpenApi(); // Serwuje dokument OpenAPI
|
||||
app.UseSwaggerUi(); // Dodaje interfejs u¿ytkownika Swagger
|
||||
//}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
31
FaKrosnoApi/Properties/launchSettings.json
Normal file
31
FaKrosnoApi/Properties/launchSettings.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:16065",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger/index.html",
|
||||
"applicationUrl": "http://localhost:5152",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger/index.html",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
FaKrosnoApi/appsettings.Development.json
Normal file
8
FaKrosnoApi/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
18
FaKrosnoApi/appsettings.json
Normal file
18
FaKrosnoApi/appsettings.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"FaKrosnoConnection": "Server=192.168.0.7;Database=fakrosnotest;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true",
|
||||
"SytelineSaAppConnection": "Server=192.168.0.7;Database=SL_PRODTEST_SA_APP;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "ThisIsASecretKeyForJwt",
|
||||
"Issuer": "FaKrosnoApi",
|
||||
"Audience": "FaKrosnoClient"
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user