Skip to content

Commit 734f1c8

Browse files
Sullivan008Kozák Péter
authored and
Kozák Péter
committedJul 18, 2019
ASP.NET MVC Core - Formula One Project Initialize
0 parents  commit 734f1c8

File tree

300 files changed

+96127
-0
lines changed

Some content is hidden

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

300 files changed

+96127
-0
lines changed
 
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\Business.Entities\Business.Entities.csproj" />
13+
<ProjectReference Include="..\Core.Common\Core.Common.csproj" />
14+
<ProjectReference Include="..\Data.DataAccessLayer\Data.DataAccessLayer.csproj" />
15+
</ItemGroup>
16+
17+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
using Business.Engine.BusinessEngines.Interfaces;
2+
using Business.Entities.DataBaseEntities;
3+
using Core.Common.Data.DTOs;
4+
using Core.Common.Utils;
5+
using Data.DataAccessLayer.Context;
6+
using Data.DataAccessLayer.DataRepositories.Interfaces;
7+
using Data.DataAccessLayer.DataRepositories.Repositories;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Threading.Tasks;
11+
12+
namespace Business.Engine.BusinessEngines.Engines
13+
{
14+
public class TeamEngine : ITeamEngine
15+
{
16+
private readonly ITeamRepository _teamRepository;
17+
18+
public FormulaContext _ctx { get; set; }
19+
20+
/// <summary>
21+
/// Konstruktor
22+
/// </summary>
23+
public TeamEngine()
24+
{
25+
_teamRepository = new TeamRepository();
26+
}
27+
28+
public async Task<bool> AddTeam(TeamDTO teamDTO)
29+
{
30+
_teamRepository._ctx = _ctx;
31+
32+
Team insertedTeam = await _teamRepository.Add(MapTeamDTOToTeam(teamDTO));
33+
34+
if (insertedTeam != null && insertedTeam?.TeamID != 0)
35+
{
36+
return true;
37+
}
38+
39+
return false;
40+
}
41+
42+
public async Task<List<TeamDTO>> GetAllTeam()
43+
{
44+
_teamRepository._ctx = _ctx;
45+
46+
return MapTeamToTeamDTO((await _teamRepository.GetAllTeam()).ToList());
47+
}
48+
49+
public TeamDTO GetTeamByID(int id)
50+
{
51+
_teamRepository._ctx = _ctx;
52+
53+
TeamDTO foundTeam = MapTeamToTeamDTO(_teamRepository.GetTeamByID(id).Result);
54+
55+
if (foundTeam != null && foundTeam?.TeamID != 0)
56+
{
57+
return foundTeam;
58+
}
59+
else
60+
{
61+
return new TeamDTO();
62+
}
63+
}
64+
65+
public async Task<bool> UpdateTeam(TeamDTO teamDTO)
66+
{
67+
_teamRepository._ctx = _ctx;
68+
69+
Team updatedTeam = await _teamRepository.Update(MapTeamDTOToTeam(teamDTO));
70+
71+
if(updatedTeam != null)
72+
{
73+
return true;
74+
}
75+
76+
return false;
77+
}
78+
79+
public async Task<bool> DeleteTeamByID(int id)
80+
{
81+
_teamRepository._ctx = _ctx;
82+
83+
Team deletedTeam = await _teamRepository.Delete(new Team() { TeamID = id });
84+
85+
if(deletedTeam != null && deletedTeam?.TeamID != 0)
86+
{
87+
return true;
88+
}
89+
90+
return false;
91+
}
92+
93+
#region HELPER Methods
94+
private List<TeamDTO> MapTeamToTeamDTO(List<Team> teams)
95+
{
96+
List<TeamDTO> teamDTOs = new List<TeamDTO>();
97+
98+
foreach (Team item in teams)
99+
{
100+
TeamDTO dto = new TeamDTO();
101+
102+
PropertyMapper.MapProperties(item, dto);
103+
104+
teamDTOs.Add(dto);
105+
}
106+
107+
return teamDTOs;
108+
}
109+
110+
private Team MapTeamDTOToTeam(TeamDTO teamDTO)
111+
{
112+
Team team = new Team();
113+
114+
PropertyMapper.MapProperties<TeamDTO, Team>(teamDTO, team);
115+
116+
return team;
117+
}
118+
119+
private TeamDTO MapTeamToTeamDTO(Team team)
120+
{
121+
TeamDTO teamDTO = new TeamDTO();
122+
123+
PropertyMapper.MapProperties<Team, TeamDTO>(team, teamDTO);
124+
125+
return teamDTO;
126+
}
127+
#endregion
128+
}
129+
}

0 commit comments

Comments
 (0)
Please sign in to comment.