Skip to content

Commit 854ac8f

Browse files
authored
Merge pull request #21 from Amitpnk/develop
Develop
2 parents fbb4d96 + 61f04a1 commit 854ac8f

File tree

13 files changed

+135
-13
lines changed

13 files changed

+135
-13
lines changed

Assert/Onion.png

-83.8 KB
Binary file not shown.

Assert/Step3.png

-1.99 KB
Loading

Assert/icon.png

-49.8 KB
Binary file not shown.

CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
Version will be updated as it is released to Microsoft Marketplace
6+
7+
## Version 1.3
8+
9+
### Added API Versioning
10+
11+
* Added API versioning
12+
* Fixed bug related to update
13+
14+
## Version 1.2
15+
16+
### Fixed bug
17+
18+
* Fixed bug
19+
20+
## Version 1.0
21+
22+
### Code refactored
23+
24+
* Removed data layer and refactored
25+
26+
## Version 0.6
27+
28+
### Added feature
29+
30+
* Swagger
31+
* CQRS Pattern
32+
* Loggings - seriLog
33+
34+
## Version 0.5
35+
36+
### Added feature
37+
38+
* Email feature
39+
40+
## Version 0.2 - 0.4
41+
42+
### Fixed issue related to Project template
43+
44+
* Project template
45+
46+
## Version 0.1 - 26-Jun-2020
47+
48+
### Initial release
49+
50+
* Application is implemented on Onion architecture
51+
* API
52+
* Entityframework Core
53+
* Expection handling
54+
* Automapper
55+
* Unit testing via NUnit
56+
* Integration testing via NUnit
57+

OnionArchitecture/OA.Infrastructure/Extension/ConfigureServiceContainer.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AutoMapper;
2+
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.EntityFrameworkCore;
34
using Microsoft.Extensions.Configuration;
45
using Microsoft.Extensions.DependencyInjection;
@@ -90,6 +91,16 @@ public static void AddController(this IServiceCollection serviceCollection)
9091
// //var assembly = AppDomain.CurrentDomain.Load("OA.Service");
9192
// services.AddMediatR(Assembly.GetExecutingAssembly());
9293
//}
94+
public static void AddVersion(this IServiceCollection serviceCollection)
95+
{
96+
serviceCollection.AddApiVersioning(config =>
97+
{
98+
config.DefaultApiVersion = new ApiVersion(1, 0);
99+
config.AssumeDefaultVersionWhenUnspecified = true;
100+
config.ReportApiVersions = true;
101+
});
102+
}
103+
93104

94105
}
95106
}

OnionArchitecture/OA.Infrastructure/OA.Infrastructure.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
1414
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.5" />
15+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
1516
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5">
1617
<PrivateAssets>all</PrivateAssets>
1718
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

OnionArchitecture/OA.Service/Features/CustomerFeatures/Commands/UpdateCustomerCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public async Task<int> Handle(UpdateCustomerCommand request, CancellationToken c
3737
}
3838
else
3939
{
40-
var customer = new Customer();
41-
customer.CustomerName = request.CustomerName;
42-
customer.ContactName = request.ContactName;
40+
cust.CustomerName = request.CustomerName;
41+
cust.ContactName = request.ContactName;
42+
_context.Customers.Update(cust);
4343
await _context.SaveChangesAsync();
4444
return cust.Id;
4545
}

OnionArchitecture/OA/Controllers/CustomerController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
namespace OA.Controllers
99
{
10-
[Route("api/Customer")]
1110
[ApiController]
11+
[Route("api/v{version:apiVersion}/Customer")]
12+
[ApiVersion("1.0")]
1213
public class CustomerController : ControllerBase
1314
{
1415
private IMediator _mediator;
@@ -40,7 +41,7 @@ public async Task<IActionResult> Delete(int id)
4041
}
4142

4243

43-
[HttpPut("[action]")]
44+
[HttpPut("{id}")]
4445
public async Task<IActionResult> Update(int id, UpdateCustomerCommand command)
4546
{
4647
if (id != command.Id)

OnionArchitecture/OA/Controllers/MailController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
namespace OA.Controllers
77
{
8-
[Route("api/Mail")]
98
[ApiController]
9+
[Route("api/v{version:apiVersion}/Mail")]
10+
[ApiVersion("1.0")]
1011
public class MailController : ControllerBase
1112
{
1213
private readonly IMailService mailService;

OnionArchitecture/OA/Startup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public void ConfigureServices(IServiceCollection services)
4343

4444
services.AddMediatorCQRS();
4545

46+
services.AddVersion();
4647

4748
}
4849

0 commit comments

Comments
 (0)