Skip to content

Develop to master #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy ASP.Net Core app to Azure Web App - AutoHubAPI

on:
push:
branches:
- develop
workflow_dispatch:

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"

- name: Build with dotnet
run: dotnet build --configuration Release

- name: Run tests with dotnet
run: dotnet test -c Release --no-build --no-restore

- name: dotnet publish
run: dotnet publish -c Release -o ./publish

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: .net-app
path: ./publish

deploy:
runs-on: windows-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: .net-app

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_5BD849A4FE6E4C0DB7AD0EB5E846624D }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_178D5841557B44B6846E2B87FE48DD59 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_028CAC2C085347419D18855B1FF0AC4C }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'AutoHubAPI'
slot-name: 'Production'
package: .

38 changes: 20 additions & 18 deletions AutoHub.API/AutoHub.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<UserSecretsId>d05e2abf-9390-4c8d-8b73-ec1fade60694</UserSecretsId>
<LangVersion>latestmajor</LangVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -19,31 +21,31 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="FluentValidation" Version="11.5.2" />
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="MailKit" Version="3.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PackageReference Include="MailKit" Version="4.8.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.6" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14" />
<PackageReference Include="Quartz" Version="3.6.2" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.6.2" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.6.2" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.55.0.65544">
<PackageReference Include="Newtonsoft.Json.Schema" Version="4.0.1" />
<PackageReference Include="Quartz" Version="3.13.0" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.13.0" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.13.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.28.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
<PackageReference Include="Swashbuckle.AspNetCore.ReDoc" Version="6.8.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.8.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.8.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.8.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 5 additions & 12 deletions AutoHub.API/Controllers/AuthenticationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ namespace AutoHub.API.Controllers;
[AllowAnonymous]
[Route("api/[controller]")]
[Produces("application/json")]
public class AuthenticationController : Controller
public class AuthenticationController(IUserService userService, IMapper mapper) : ControllerBase
{
private readonly IMapper _mapper;
private readonly IUserService _userService;

public AuthenticationController(IUserService userService, IMapper mapper)
{
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
_mapper = mapper;
}
private readonly IUserService _userService = userService ?? throw new ArgumentNullException(nameof(userService));

/// <summary>
/// Log-in with credentials.
Expand All @@ -43,9 +36,9 @@ public async Task<IActionResult> LoginUser([FromBody] UserLoginRequest model)
{
await _userService.Logout();

var mappedUser = _mapper.Map<UserLoginRequestDTO>(model);
var mappedUser = mapper.Map<UserLoginRequestDTO>(model);
var authModel = await _userService.Login(mappedUser);
var mappedAuthModel = _mapper.Map<UserLoginResponse>(authModel);
var mappedAuthModel = mapper.Map<UserLoginResponse>(authModel);

return Ok(mappedAuthModel);
}
Expand All @@ -63,7 +56,7 @@ public async Task<IActionResult> LoginUser([FromBody] UserLoginRequest model)
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> RegisterUser([FromBody] UserRegisterRequest model)
{
var mappedUser = _mapper.Map<UserRegisterRequestDTO>(model);
var mappedUser = mapper.Map<UserRegisterRequestDTO>(model);
await _userService.Register(mappedUser);

return StatusCode((int)HttpStatusCode.Created);
Expand Down
15 changes: 4 additions & 11 deletions AutoHub.API/Controllers/CarBrandController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@ namespace AutoHub.API.Controllers;
[Authorize]
[Route("api/[controller]s")]
[Produces("application/json")]
public class CarBrandController : Controller
public class CarBrandController(ICarBrandService carBrandService, IMapper mapper) : ControllerBase
{
private readonly ICarBrandService _carBrandService;
private readonly IMapper _mapper;

public CarBrandController(ICarBrandService carBrandService, IMapper mapper)
{
_carBrandService = carBrandService ?? throw new ArgumentNullException(nameof(carBrandService));
_mapper = mapper;
}
private readonly ICarBrandService _carBrandService = carBrandService ?? throw new ArgumentNullException(nameof(carBrandService));

/// <summary>
/// Get all car brands.
Expand Down Expand Up @@ -68,7 +61,7 @@ public async Task<IActionResult> GetAllCarBrands([FromQuery] PaginationParameter
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> CreateCarBrand([FromBody] CarBrandCreateRequest model)
{
var mappedCarBrand = _mapper.Map<CarBrandCreateRequestDTO>(model);
var mappedCarBrand = mapper.Map<CarBrandCreateRequestDTO>(model);
await _carBrandService.Create(mappedCarBrand);

return StatusCode((int)HttpStatusCode.Created);
Expand All @@ -95,7 +88,7 @@ public async Task<IActionResult> CreateCarBrand([FromBody] CarBrandCreateRequest
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> UpdateCarBrand(int carBrandId, [FromBody] CarBrandUpdateRequest model)
{
var mappedCarBrand = _mapper.Map<CarBrandUpdateRequestDTO>(model);
var mappedCarBrand = mapper.Map<CarBrandUpdateRequestDTO>(model);
await _carBrandService.Update(carBrandId, mappedCarBrand);

return NoContent();
Expand Down
15 changes: 4 additions & 11 deletions AutoHub.API/Controllers/CarColorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@ namespace AutoHub.API.Controllers;
[Authorize]
[Route("api/[controller]s")]
[Produces("application/json")]
public class CarColorController : Controller
public class CarColorController(ICarColorService carColorService, IMapper mapper) : ControllerBase
{
private readonly ICarColorService _carColorService;
private readonly IMapper _mapper;

public CarColorController(ICarColorService carColorService, IMapper mapper)
{
_carColorService = carColorService ?? throw new ArgumentNullException(nameof(carColorService));
_mapper = mapper;
}
private readonly ICarColorService _carColorService = carColorService ?? throw new ArgumentNullException(nameof(carColorService));

/// <summary>
/// Get all car colors.
Expand Down Expand Up @@ -69,7 +62,7 @@ public async Task<IActionResult> GetAllCarColors([FromQuery] PaginationParameter
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> CreateCarColor([FromBody] CarColorCreateRequest model)
{
var mappedCarColor = _mapper.Map<CarColorCreateRequestDTO>(model);
var mappedCarColor = mapper.Map<CarColorCreateRequestDTO>(model);
await _carColorService.Create(mappedCarColor);

return StatusCode((int)HttpStatusCode.Created);
Expand All @@ -96,7 +89,7 @@ public async Task<IActionResult> CreateCarColor([FromBody] CarColorCreateRequest
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> UpdateCarColor(int carColorId, [FromBody] CarColorUpdateRequest model)
{
var mappedCarColor = _mapper.Map<CarColorUpdateRequestDTO>(model);
var mappedCarColor = mapper.Map<CarColorUpdateRequestDTO>(model);
await _carColorService.Update(carColorId, mappedCarColor);

return NoContent();
Expand Down
17 changes: 5 additions & 12 deletions AutoHub.API/Controllers/CarController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,9 @@ namespace AutoHub.API.Controllers;
[Authorize]
[Route("api/[controller]s")]
[Produces("application/json")]
public class CarController : Controller
public class CarController(ICarService carService, IMapper mapper) : ControllerBase
{
private readonly ICarService _carService;
private readonly IMapper _mapper;

public CarController(ICarService carService, IMapper mapper)
{
_carService = carService ?? throw new ArgumentNullException(nameof(carService));
_mapper = mapper;
}
private readonly ICarService _carService = carService ?? throw new ArgumentNullException(nameof(carService));

/// <summary>
/// Get all cars.
Expand Down Expand Up @@ -67,7 +60,7 @@ public async Task<IActionResult> GetAllCars([FromQuery] PaginationParameters pag
public async Task<IActionResult> GetCarById(int carId)
{
var car = await _carService.GetById(carId);
var mappedCar = _mapper.Map<CarResponse>(car);
var mappedCar = mapper.Map<CarResponse>(car);

return Ok(mappedCar);
}
Expand All @@ -90,7 +83,7 @@ public async Task<IActionResult> GetCarById(int carId)
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> CreateCar([FromBody] CarCreateRequest model)
{
var mappedCar = _mapper.Map<CarCreateRequestDTO>(model);
var mappedCar = mapper.Map<CarCreateRequestDTO>(model);
await _carService.Create(mappedCar);

return StatusCode((int)HttpStatusCode.Created);
Expand Down Expand Up @@ -118,7 +111,7 @@ public async Task<IActionResult> CreateCar([FromBody] CarCreateRequest model)
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> UpdateCar(int carId, [FromBody] CarUpdateRequest model)
{
var mappedCar = _mapper.Map<CarUpdateRequestDTO>(model);
var mappedCar = mapper.Map<CarUpdateRequestDTO>(model);
await _carService.Update(carId, mappedCar);

return NoContent();
Expand Down
15 changes: 4 additions & 11 deletions AutoHub.API/Controllers/CarModelController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@ namespace AutoHub.API.Controllers;
[Authorize]
[Route("api/[controller]s")]
[Produces("application/json")]
public class CarModelController : Controller
public class CarModelController(ICarModelService carModelService, IMapper mapper) : ControllerBase
{
private readonly ICarModelService _carModelService;
private readonly IMapper _mapper;

public CarModelController(ICarModelService carModelService, IMapper mapper)
{
_carModelService = carModelService ?? throw new ArgumentNullException(nameof(carModelService));
_mapper = mapper;
}
private readonly ICarModelService _carModelService = carModelService ?? throw new ArgumentNullException(nameof(carModelService));

/// <summary>
/// Get all car models.
Expand Down Expand Up @@ -68,7 +61,7 @@ public async Task<IActionResult> GetAllCarModels([FromQuery] PaginationParameter
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> CreateCarModel([FromBody] CarModelCreateRequest model)
{
var mappedCarModel = _mapper.Map<CarModelCreateRequestDTO>(model);
var mappedCarModel = mapper.Map<CarModelCreateRequestDTO>(model);
await _carModelService.Create(mappedCarModel);

return StatusCode((int)HttpStatusCode.Created);
Expand All @@ -94,7 +87,7 @@ public async Task<IActionResult> CreateCarModel([FromBody] CarModelCreateRequest
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> UpdateCarModel(int carModelId, [FromBody] CarModelUpdateRequest model)
{
var mappedCarModel = _mapper.Map<CarModelUpdateRequestDTO>(model);
var mappedCarModel = mapper.Map<CarModelUpdateRequestDTO>(model);
await _carModelService.Update(carModelId, mappedCarModel);

return NoContent();
Expand Down
13 changes: 3 additions & 10 deletions AutoHub.API/Controllers/LotBidController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@ namespace AutoHub.API.Controllers;
[Authorize]
[Route("api/Lots/{lotId}/Bids")]
[Produces("application/json")]
public class LotBidController : Controller
public class LotBidController(IBidService bidService, IMapper mapper) : ControllerBase
{
private readonly IBidService _bidService;
private readonly IMapper _mapper;

public LotBidController(IBidService bidService, IMapper mapper)
{
_bidService = bidService ?? throw new ArgumentNullException(nameof(bidService));
_mapper = mapper;
}
private readonly IBidService _bidService = bidService ?? throw new ArgumentNullException(nameof(bidService));

/// <summary>
/// Get all bids of specific lot.
Expand Down Expand Up @@ -74,7 +67,7 @@ public async Task<IActionResult> GetLotBids(int lotId, [FromQuery] PaginationPar
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> CreateBid(int lotId, [FromBody] BidCreateRequest model)
{
var mappedBid = _mapper.Map<BidCreateRequestDTO>(model);
var mappedBid = mapper.Map<BidCreateRequestDTO>(model);
await _bidService.Create(lotId, mappedBid);

return StatusCode((int)HttpStatusCode.Created);
Expand Down
Loading
Loading