Skip to content

Commit 2d29b24

Browse files
Revert "Updated base project and .NET Core version to 3.1"
This reverts commit e77e68c.
1 parent d5fe65a commit 2d29b24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+493
-494
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@
88
/LoggerService/bin
99
/Repository/obj
1010
/Repository/bin
11-
/.vs/AccountOwnerServer/v16
12-
/AccountOwnerServer/*.user
13-
/.vs/AccountOwnerServer/DesignTimeBuild/*.dtbcache

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: csharp
2+
mono: none
3+
dotnet: 2.0
4+
script:
5+
- dotnet restore
6+
- dotnet build

AccountOwnerServer.sln

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29424.173
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26730.3
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountOwnerServer", "AccountOwnerServer\AccountOwnerServer.csproj", "{D9142A6E-9687-4BA4-9CF9-A9AFF006E3DF}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountOwnerServer", "AccountOwnerServer\AccountOwnerServer.csproj", "{73FB08B8-4033-4116-B3AC-EC8253B024D4}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{E75B1842-10BD-4BF3-A96A-830220E57332}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{52725034-B791-4DF1-A227-02EDB5BF78E0}"
99
EndProject
10-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LoggerService", "LoggerService\LoggerService.csproj", "{DA66E4D3-1CDD-407D-9900-FC27F5AF8F06}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LoggerService", "LoggerService\LoggerService.csproj", "{A190AF01-84DC-40A8-BEF3-C015825C8B30}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{3466888D-D523-4180-B3E4-69953F45F520}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{8CD97B3F-C616-469C-80A2-A1B366611487}"
1313
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repository", "Repository\Repository.csproj", "{7EB45A88-65DE-4A64-852A-3B6921B32D2E}"
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repository", "Repository\Repository.csproj", "{CC0B1C81-CB8A-412C-BD48-BCBC3F1A1CD0}"
1515
EndProject
1616
Global
1717
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1818
Debug|Any CPU = Debug|Any CPU
1919
Release|Any CPU = Release|Any CPU
2020
EndGlobalSection
2121
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22-
{D9142A6E-9687-4BA4-9CF9-A9AFF006E3DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23-
{D9142A6E-9687-4BA4-9CF9-A9AFF006E3DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{D9142A6E-9687-4BA4-9CF9-A9AFF006E3DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
25-
{D9142A6E-9687-4BA4-9CF9-A9AFF006E3DF}.Release|Any CPU.Build.0 = Release|Any CPU
26-
{E75B1842-10BD-4BF3-A96A-830220E57332}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27-
{E75B1842-10BD-4BF3-A96A-830220E57332}.Debug|Any CPU.Build.0 = Debug|Any CPU
28-
{E75B1842-10BD-4BF3-A96A-830220E57332}.Release|Any CPU.ActiveCfg = Release|Any CPU
29-
{E75B1842-10BD-4BF3-A96A-830220E57332}.Release|Any CPU.Build.0 = Release|Any CPU
30-
{DA66E4D3-1CDD-407D-9900-FC27F5AF8F06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31-
{DA66E4D3-1CDD-407D-9900-FC27F5AF8F06}.Debug|Any CPU.Build.0 = Debug|Any CPU
32-
{DA66E4D3-1CDD-407D-9900-FC27F5AF8F06}.Release|Any CPU.ActiveCfg = Release|Any CPU
33-
{DA66E4D3-1CDD-407D-9900-FC27F5AF8F06}.Release|Any CPU.Build.0 = Release|Any CPU
34-
{3466888D-D523-4180-B3E4-69953F45F520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35-
{3466888D-D523-4180-B3E4-69953F45F520}.Debug|Any CPU.Build.0 = Debug|Any CPU
36-
{3466888D-D523-4180-B3E4-69953F45F520}.Release|Any CPU.ActiveCfg = Release|Any CPU
37-
{3466888D-D523-4180-B3E4-69953F45F520}.Release|Any CPU.Build.0 = Release|Any CPU
38-
{7EB45A88-65DE-4A64-852A-3B6921B32D2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39-
{7EB45A88-65DE-4A64-852A-3B6921B32D2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
40-
{7EB45A88-65DE-4A64-852A-3B6921B32D2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
41-
{7EB45A88-65DE-4A64-852A-3B6921B32D2E}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{73FB08B8-4033-4116-B3AC-EC8253B024D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{73FB08B8-4033-4116-B3AC-EC8253B024D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{73FB08B8-4033-4116-B3AC-EC8253B024D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{73FB08B8-4033-4116-B3AC-EC8253B024D4}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{52725034-B791-4DF1-A227-02EDB5BF78E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{52725034-B791-4DF1-A227-02EDB5BF78E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{52725034-B791-4DF1-A227-02EDB5BF78E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{52725034-B791-4DF1-A227-02EDB5BF78E0}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{A190AF01-84DC-40A8-BEF3-C015825C8B30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{A190AF01-84DC-40A8-BEF3-C015825C8B30}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{A190AF01-84DC-40A8-BEF3-C015825C8B30}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{A190AF01-84DC-40A8-BEF3-C015825C8B30}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{8CD97B3F-C616-469C-80A2-A1B366611487}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{8CD97B3F-C616-469C-80A2-A1B366611487}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{8CD97B3F-C616-469C-80A2-A1B366611487}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{8CD97B3F-C616-469C-80A2-A1B366611487}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{CC0B1C81-CB8A-412C-BD48-BCBC3F1A1CD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{CC0B1C81-CB8A-412C-BD48-BCBC3F1A1CD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{CC0B1C81-CB8A-412C-BD48-BCBC3F1A1CD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{CC0B1C81-CB8A-412C-BD48-BCBC3F1A1CD0}.Release|Any CPU.Build.0 = Release|Any CPU
4242
EndGlobalSection
4343
GlobalSection(SolutionProperties) = preSolution
4444
HideSolutionNode = FALSE
4545
EndGlobalSection
4646
GlobalSection(ExtensibilityGlobals) = postSolution
47-
SolutionGuid = {12A94BCC-D511-439A-9D3B-C1253CB1C879}
47+
SolutionGuid = {86DE07EE-BE1C-4AAB-ADAA-224170CF42B0}
4848
EndGlobalSection
4949
EndGlobal

AccountOwnerServer/AccountOwnerServer.csproj

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
11-
<PrivateAssets>all</PrivateAssets>
12-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13-
</PackageReference>
14-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0" />
15-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
16-
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
8+
<Folder Include="wwwroot\" />
179
</ItemGroup>
1810

1911
<ItemGroup>
12+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
13+
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.1" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<ProjectReference Include="..\Contracts\Contracts.csproj" />
22+
<ProjectReference Include="..\Entities\Entities.csproj" />
2023
<ProjectReference Include="..\LoggerService\LoggerService.csproj" />
2124
<ProjectReference Include="..\Repository\Repository.csproj" />
2225
</ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,97 @@
1-
using AutoMapper;
2-
using Contracts;
3-
using Entities.DataTransferObjects;
1+
using Contracts;
2+
using Entities.Extensions;
43
using Entities.Models;
54
using Microsoft.AspNetCore.Mvc;
65
using System;
7-
using System.Collections.Generic;
8-
using System.Linq;
96

107
namespace AccountOwnerServer.Controllers
118
{
12-
[Route("api/owner")]
13-
[ApiController]
14-
public class OwnerController : ControllerBase
15-
{
16-
private ILoggerManager _logger;
9+
[Route("api/owner")]
10+
public class OwnerController : Controller
11+
{
12+
private ILoggerManager _logger;
1713
private IRepositoryWrapper _repository;
18-
private IMapper _mapper;
19-
20-
public OwnerController(ILoggerManager logger, IRepositoryWrapper repository, IMapper mapper)
21-
{
22-
_logger = logger;
14+
15+
public OwnerController(ILoggerManager logger, IRepositoryWrapper repository)
16+
{
17+
_logger = logger;
2318
_repository = repository;
24-
_mapper = mapper;
2519
}
26-
27-
[HttpGet]
28-
public IActionResult GetAllOwners()
29-
{
30-
try
31-
{
32-
var owners = _repository.Owner.GetAllOwners();
20+
21+
[HttpGet]
22+
public IActionResult GetAllOwners()
23+
{
24+
try
25+
{
26+
var owners = _repository.Owner.GetAllOwners();
27+
3328
_logger.LogInfo($"Returned all owners from database.");
3429

35-
var ownersResult = _mapper.Map<IEnumerable<OwnerDto>>(owners);
36-
return Ok(ownersResult);
37-
}
38-
catch (Exception ex)
39-
{
40-
_logger.LogError($"Something went wrong inside GetAllOwners action: {ex.Message}");
41-
return StatusCode(500, "Internal server error");
42-
}
30+
return Ok(owners);
31+
}
32+
catch (Exception ex)
33+
{
34+
_logger.LogError($"Something went wrong inside GetAllOwners action: {ex.Message}");
35+
return StatusCode(500, "Internal server error");
36+
}
4337
}
4438

45-
[HttpGet("{id}", Name = "OwnerById")]
46-
public IActionResult GetOwnerById(Guid id)
47-
{
48-
try
49-
{
50-
var owner = _repository.Owner.GetOwnerById(id);
51-
if (owner == null)
52-
{
53-
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
54-
return NotFound();
55-
}
56-
else
57-
{
58-
_logger.LogInfo($"Returned owner with id: {id}");
39+
[HttpGet("{id}", Name = "OwnerById")]
40+
public IActionResult GetOwnerById(Guid id)
41+
{
42+
try
43+
{
44+
var owner = _repository.Owner.GetOwnerById(id);
5945

60-
var ownerResult = _mapper.Map<OwnerDto>(owner);
61-
return Ok(ownerResult);
62-
}
63-
}
64-
catch (Exception ex)
65-
{
66-
_logger.LogError($"Something went wrong inside GetOwnerById action: {ex.Message}");
67-
return StatusCode(500, "Internal server error");
68-
}
46+
if (owner.IsEmptyObject())
47+
{
48+
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
49+
return NotFound();
50+
}
51+
else
52+
{
53+
_logger.LogInfo($"Returned owner with id: {id}");
54+
return Ok(owner);
55+
}
56+
}
57+
catch (Exception ex)
58+
{
59+
_logger.LogError($"Something went wrong inside GetOwnerById action: {ex.Message}");
60+
return StatusCode(500, "Internal server error");
61+
}
6962
}
7063

71-
[HttpGet("{id}/account")]
72-
public IActionResult GetOwnerWithDetails(Guid id)
73-
{
74-
try
75-
{
76-
var owner = _repository.Owner.GetOwnerWithDetails(id);
77-
if (owner == null)
78-
{
79-
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
80-
return NotFound();
81-
}
82-
else
83-
{
84-
_logger.LogInfo($"Returned owner with details for id: {id}");
64+
[HttpGet("{id}/account")]
65+
public IActionResult GetOwnerWithDetails(Guid id)
66+
{
67+
try
68+
{
69+
var owner = _repository.Owner.GetOwnerWithDetails(id);
8570

86-
var ownerResult = _mapper.Map<OwnerDto>(owner);
87-
return Ok(ownerResult);
88-
}
89-
}
90-
catch (Exception ex)
91-
{
92-
_logger.LogError($"Something went wrong inside GetOwnerWithDetails action: {ex.Message}");
93-
return StatusCode(500, "Internal server error");
71+
if (owner.IsEmptyObject())
72+
{
73+
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
74+
return NotFound();
75+
}
76+
else
77+
{
78+
_logger.LogInfo($"Returned owner with details for id: {id}");
79+
return Ok(owner);
80+
}
81+
}
82+
catch (Exception ex)
83+
{
84+
_logger.LogError($"Something went wrong inside GetOwnerWithDetails action: {ex.Message}");
85+
return StatusCode(500, "Internal server error");
9486
}
9587
}
9688

9789
[HttpPost]
98-
public IActionResult CreateOwner([FromBody]OwnerForCreationDto owner)
90+
public IActionResult CreateOwner([FromBody]Owner owner)
9991
{
10092
try
10193
{
102-
if (owner == null)
94+
if (owner.IsObjectNull())
10395
{
10496
_logger.LogError("Owner object sent from client is null.");
10597
return BadRequest("Owner object is null");
@@ -111,14 +103,9 @@ public IActionResult CreateOwner([FromBody]OwnerForCreationDto owner)
111103
return BadRequest("Invalid model object");
112104
}
113105

114-
var ownerEntity = _mapper.Map<Owner>(owner);
115-
116-
_repository.Owner.CreateOwner(ownerEntity);
117-
_repository.Save();
106+
_repository.Owner.CreateOwner(owner);
118107

119-
var createdOwner = _mapper.Map<OwnerDto>(ownerEntity);
120-
121-
return CreatedAtRoute("OwnerById", new { id = createdOwner.Id }, createdOwner);
108+
return CreatedAtRoute("OwnerById", new { id = owner.Id }, owner);
122109
}
123110
catch (Exception ex)
124111
{
@@ -128,11 +115,11 @@ public IActionResult CreateOwner([FromBody]OwnerForCreationDto owner)
128115
}
129116

130117
[HttpPut("{id}")]
131-
public IActionResult UpdateOwner(Guid id, [FromBody]OwnerForUpdateDto owner)
118+
public IActionResult UpdateOwner(Guid id, [FromBody]Owner owner)
132119
{
133120
try
134121
{
135-
if (owner == null)
122+
if (owner.IsObjectNull())
136123
{
137124
_logger.LogError("Owner object sent from client is null.");
138125
return BadRequest("Owner object is null");
@@ -144,17 +131,14 @@ public IActionResult UpdateOwner(Guid id, [FromBody]OwnerForUpdateDto owner)
144131
return BadRequest("Invalid model object");
145132
}
146133

147-
var ownerEntity = _repository.Owner.GetOwnerById(id);
148-
if (ownerEntity == null)
134+
var dbOwner = _repository.Owner.GetOwnerById(id);
135+
if (dbOwner.IsEmptyObject())
149136
{
150137
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
151138
return NotFound();
152139
}
153140

154-
_mapper.Map(owner, ownerEntity);
155-
156-
_repository.Owner.UpdateOwner(ownerEntity);
157-
_repository.Save();
141+
_repository.Owner.UpdateOwner(dbOwner, owner);
158142

159143
return NoContent();
160144
}
@@ -171,14 +155,13 @@ public IActionResult DeleteOwner(Guid id)
171155
try
172156
{
173157
var owner = _repository.Owner.GetOwnerById(id);
174-
if (owner == null)
158+
if (owner.IsEmptyObject())
175159
{
176160
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
177161
return NotFound();
178162
}
179163

180164
_repository.Owner.DeleteOwner(owner);
181-
_repository.Save();
182165

183166
return NoContent();
184167
}
@@ -189,4 +172,4 @@ public IActionResult DeleteOwner(Guid id)
189172
}
190173
}
191174
}
192-
}
175+
}

0 commit comments

Comments
 (0)