Skip to content

Commit d8a40ec

Browse files
committed
Seperation of Concers - restructing project
1 parent fbc97a8 commit d8a40ec

File tree

71 files changed

+585
-3577
lines changed

Some content is hidden

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

71 files changed

+585
-3577
lines changed

LeaveManagement.Web/Configurations/MapperConfig.cs LeaveManagement.Application/Configurations/MapperConfig.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using AutoMapper;
2-
using LeaveManagement.Web.Data;
3-
using LeaveManagement.Web.Models;
2+
using LeaveManagement.Data;
3+
using LeaveManagement.Common.Models;
44

5-
namespace LeaveManagement.Web.Configurations
5+
namespace LeaveManagement.Application.Configurations
66
{
77
public class MapperConfig: Profile
88
{

LeaveManagement.Web/Contracts/IGenericRepository.cs LeaveManagement.Application/Contracts/IGenericRepository.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace LeaveManagement.Web.Contracts
1+
namespace LeaveManagement.Application.Contracts
22
{
33
public interface IGenericRepository<T> where T : class
44
{

LeaveManagement.Web/Contracts/ILeaveAllocationRepository.cs LeaveManagement.Application/Contracts/ILeaveAllocationRepository.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using LeaveManagement.Web.Data;
2-
using LeaveManagement.Web.Models;
1+
using LeaveManagement.Data;
2+
using LeaveManagement.Common.Models;
33

4-
namespace LeaveManagement.Web.Contracts
4+
namespace LeaveManagement.Application.Contracts
55
{
66
public interface ILeaveAllocationRepository : IGenericRepository<LeaveAllocation>
77
{

LeaveManagement.Web/Contracts/ILeaveRequestRepository.cs LeaveManagement.Application/Contracts/ILeaveRequestRepository.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using LeaveManagement.Web.Data;
2-
using LeaveManagement.Web.Models;
1+
using LeaveManagement.Data;
2+
using LeaveManagement.Common.Models;
33

4-
namespace LeaveManagement.Web.Contracts
4+
namespace LeaveManagement.Application.Contracts
55
{
66
public interface ILeaveRequestRepository : IGenericRepository<LeaveRequest>
77
{

LeaveManagement.Web/Contracts/ILeaveTypeRepository.cs LeaveManagement.Application/Contracts/ILeaveTypeRepository.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using LeaveManagement.Web.Data;
1+
using LeaveManagement.Data;
22

3-
namespace LeaveManagement.Web.Contracts
3+
namespace LeaveManagement.Application.Contracts
44
{
55
public interface ILeaveTypeRepository: IGenericRepository<LeaveType>
66
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="AutoMapper" Version="12.0.1" />
11+
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.5" />
12+
<ProjectReference Include="..\LeaveManagement.Data\LeaveManagement.Data.csproj" />
13+
</ItemGroup>
14+
15+
</Project>

LeaveManagement.Web/Repositories - Services/GenericRepository.cs LeaveManagement.Application/Repositories - Services/GenericRepository.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using AutoMapper;
2-
using LeaveManagement.Web.Contracts;
3-
using LeaveManagement.Web.Data;
2+
using LeaveManagement.Application.Contracts;
3+
using LeaveManagement.Data;
44
using Microsoft.EntityFrameworkCore;
55

6-
namespace LeaveManagement.Web.Services_Repositories
6+
namespace LeaveManagement.Application.Repositories___Services
77
{
88
public class GenericRepository<T> : IGenericRepository<T> where T : class
99
{

LeaveManagement.Web/Repositories - Services/LeaveAllocationRepository.cs LeaveManagement.Application/Repositories - Services/LeaveAllocationRepository.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
using AutoMapper;
22
using AutoMapper.QueryableExtensions;
3-
using LeaveManagement.Web.Constants;
4-
using LeaveManagement.Web.Contracts;
5-
using LeaveManagement.Web.Data;
6-
using LeaveManagement.Web.Models;
7-
using LeaveManagement.Web.Services;
8-
using LeaveManagement.Web.Services_Repositories;
3+
using LeaveManagement.Common.Constants;
4+
using LeaveManagement.Application.Contracts;
5+
using LeaveManagement.Data;
6+
using LeaveManagement.Common.Models;
7+
//using LeaveManagement.Web.Services;
8+
using LeaveManagement.Application.Repositories___Services;
99
using Microsoft.AspNetCore.Identity;
1010
using Microsoft.AspNetCore.Identity.UI.Services;
1111
using Microsoft.EntityFrameworkCore;
1212

13-
namespace LeaveManagement.Web.Repositories___Services
13+
namespace LeaveManagement.Application.Repositories___Services
1414
{
1515
public class LeaveAllocationRepository : GenericRepository<LeaveAllocation>, ILeaveAllocationRepository
1616
{

LeaveManagement.Web/Repositories - Services/LeaveRequestRepository.cs LeaveManagement.Application/Repositories - Services/LeaveRequestRepository.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using AutoMapper;
22
using AutoMapper.QueryableExtensions;
3-
using LeaveManagement.Web.Contracts;
4-
using LeaveManagement.Web.Data;
5-
using LeaveManagement.Web.Models;
6-
using LeaveManagement.Web.Services_Repositories;
3+
using LeaveManagement.Application.Contracts;
4+
using LeaveManagement.Data;
5+
using LeaveManagement.Common.Models;
6+
using LeaveManagement.Application.Repositories___Services;
7+
using Microsoft.AspNetCore.Http;
78
using Microsoft.AspNetCore.Identity;
89
using Microsoft.AspNetCore.Identity.UI.Services;
910
using Microsoft.EntityFrameworkCore;
1011

11-
namespace LeaveManagement.Web.Repositories___Services
12+
namespace LeaveManagement.Application.Repositories___Services
1213
{
1314
public class LeaveRequestRepository : GenericRepository<LeaveRequest>, ILeaveRequestRepository
1415
{

LeaveManagement.Web/Repositories - Services/LeaveTypeRepository.cs LeaveManagement.Application/Repositories - Services/LeaveTypeRepository.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using LeaveManagement.Web.Contracts;
2-
using LeaveManagement.Web.Data;
1+
using LeaveManagement.Application.Contracts;
2+
using LeaveManagement.Data;
33

4-
namespace LeaveManagement.Web.Services_Repositories
4+
namespace LeaveManagement.Application.Repositories___Services
55
{
66
public class LeaveTypeRepository : GenericRepository<LeaveType>, ILeaveTypeRepository
77
{

LeaveManagement.Web/Constants/Roles.cs LeaveManagement.Common/Constants/Roles.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Runtime.CompilerServices;
2-
3-
namespace LeaveManagement.Web.Constants
1+
namespace LeaveManagement.Common.Constants
42
{
53
public static class Roles
64
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
11+
</ItemGroup>
12+
13+
</Project>

LeaveManagement.Web/Models/AdminLeaveRequestViewVM.cs LeaveManagement.Common/Models/AdminLeaveRequestViewVM.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
22

3-
namespace LeaveManagement.Web.Models
3+
namespace LeaveManagement.Common.Models
44
{
55
public class AdminLeaveRequestViewVM
66
{

LeaveManagement.Web/Models/EmployeeAllocationVM.cs LeaveManagement.Common/Models/EmployeeAllocationVM.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace LeaveManagement.Web.Models
1+
namespace LeaveManagement.Common.Models
22
{
33
public class EmployeeAllocationVM: EmployeesListVM
44
{

LeaveManagement.Web/Models/EmployeeLeaveRequestViewVM.cs LeaveManagement.Common/Models/EmployeeLeaveRequestViewVM.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace LeaveManagement.Web.Models
1+
namespace LeaveManagement.Common.Models
22
{
33
public class EmployeeLeaveRequestViewVM
44
{

LeaveManagement.Web/Models/EmployeesListVM.cs LeaveManagement.Common/Models/EmployeesListVM.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
22

3-
namespace LeaveManagement.Web.Models
3+
namespace LeaveManagement.Common.Models
44
{
55
public class EmployeesListVM
66
{

LeaveManagement.Web/Models/ErrorViewModel.cs LeaveManagement.Common/Models/ErrorViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace LeaveManagement.Web.Models
1+
namespace LeaveManagement.Common.Models
22
{
33
public class ErrorViewModel
44
{

LeaveManagement.Web/Models/LeaveAllocationEditVM.cs LeaveManagement.Common/Models/LeaveAllocationEditVM.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace LeaveManagement.Web.Models
1+
namespace LeaveManagement.Common.Models
22
{
33
public class LeaveAllocationEditVM: LeaveAllocationVM
44
{

LeaveManagement.Web/Models/LeaveAllocationVM.cs LeaveManagement.Common/Models/LeaveAllocationVM.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
using LeaveManagement.Web.Data;
2-
using System.ComponentModel.DataAnnotations;
3-
using System.ComponentModel.DataAnnotations.Schema;
1+
using System.ComponentModel.DataAnnotations;
42

5-
namespace LeaveManagement.Web.Models
3+
namespace LeaveManagement.Common.Models
64
{
75
public class LeaveAllocationVM
86
{
97
[Required]
108
public int Id { get; set; }
11-
[Display(Name="Number of Days")]
9+
[Display(Name = "Number of Days")]
1210
[Required]
13-
[Range(1,21, ErrorMessage = "Invalid number entered")]
11+
[Range(1, 21, ErrorMessage = "Invalid number entered")]
1412
public int NumberOfDays { get; set; }
1513
[Required]
1614
[Display(Name = "Allocation Period")]

LeaveManagement.Web/Models/LeaveRequestCreateVM.cs LeaveManagement.Common/Models/LeaveRequestCreateVM.cs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
using LeaveManagement.Web.Data;
2-
using Microsoft.AspNetCore.Mvc.Rendering;
1+
using Microsoft.AspNetCore.Mvc.Rendering;
32
//using Microsoft.Build.Framework;
43
using System.ComponentModel;
54
using System.ComponentModel.DataAnnotations;
6-
using System.ComponentModel.DataAnnotations.Schema;
7-
using System.Drawing;
85

9-
namespace LeaveManagement.Web.Models
6+
namespace LeaveManagement.Common.Models
107
{
11-
public class LeaveRequestCreateVM: IValidatableObject
8+
public class LeaveRequestCreateVM : IValidatableObject
129
{
13-
10+
1411
[Required]
1512
[DisplayName("Start Date")]
1613
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}")]
@@ -28,7 +25,7 @@ public class LeaveRequestCreateVM: IValidatableObject
2825
[DisplayName("Comments")]
2926
public string? RequestComments { get; set; }
3027
public string? RequestingEmployeeId { get; set; }
31-
28+
3229
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
3330
{
3431
if (StartDate > EndDate)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace LeaveManagement.Common.Models
4+
{
5+
public class LeaveRequestVM : LeaveRequestCreateVM
6+
{
7+
public int Id { get; set; }
8+
public bool? Approved { get; set; }
9+
public bool Cancelled { get; set; }
10+
[Display(Name = "Date requested")]
11+
public DateTime DateCreated { get; set; }
12+
[Display(Name = "Leave Type")]
13+
public LeaveTypeVM? LeaveType { get; set; }
14+
15+
public EmployeesListVM Employee { get; set; }
16+
//public string? RequestingEmployeeId { get; set; }
17+
}
18+
}

LeaveManagement.Web/Models/LeaveTypeVM.cs LeaveManagement.Common/Models/LeaveTypeVM.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.ComponentModel;
22
using System.ComponentModel.DataAnnotations;
33

4-
namespace LeaveManagement.Web.Models
4+
namespace LeaveManagement.Common.Models
55
{
66
public class LeaveTypeVM
77
{

LeaveManagement.Web/Data/ApplicationDbContext.cs LeaveManagement.Data/ApplicationDbContext.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
using LeaveManagement.Web.Configurations.Entities;
1+
using LeaveManagement.Data.Configurations.Entities;
22
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
33
using Microsoft.EntityFrameworkCore;
4-
using LeaveManagement.Web.Models;
54

6-
namespace LeaveManagement.Web.Data
5+
namespace LeaveManagement.Data
76
{
87
public class ApplicationDbContext : IdentityDbContext<Employee>
98
{

LeaveManagement.Web/Data/BaseEntity.cs LeaveManagement.Data/BaseEntity.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace LeaveManagement.Web.Data
1+
namespace LeaveManagement.Data
22
{
33
public abstract class BaseEntity
44
{

LeaveManagement.Web/Configurations/Entities/RoleSeedConfiguration.cs LeaveManagement.Data/Configurations/Entities/RoleSeedConfiguration.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using LeaveManagement.Web.Constants;
1+
using LeaveManagement.Common.Constants;
22
using Microsoft.AspNetCore.Identity;
33
using Microsoft.EntityFrameworkCore;
44
using Microsoft.EntityFrameworkCore.Metadata.Builders;
55

6-
namespace LeaveManagement.Web.Configurations.Entities
6+
namespace LeaveManagement.Data.Configurations.Entities
77
{
88
internal class RoleSeedConfiguration : IEntityTypeConfiguration<IdentityRole>
99
{

LeaveManagement.Web/Configurations/Entities/UserRoleSeedConfiguration.cs LeaveManagement.Data/Configurations/Entities/UserRoleSeedConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Microsoft.EntityFrameworkCore;
33
using Microsoft.EntityFrameworkCore.Metadata.Builders;
44

5-
namespace LeaveManagement.Web.Configurations.Entities
5+
namespace LeaveManagement.Data.Configurations.Entities
66
{
77
internal class UserRoleSeedConfiguration : IEntityTypeConfiguration<IdentityUserRole<string>>
88
{

LeaveManagement.Web/Configurations/Entities/UserSeedConfiguration.cs LeaveManagement.Data/Configurations/Entities/UserSeedConfiguration.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
using LeaveManagement.Web.Data;
2-
using Microsoft.AspNetCore.Identity;
1+
using Microsoft.AspNetCore.Identity;
32
using Microsoft.EntityFrameworkCore;
43
using Microsoft.EntityFrameworkCore.Metadata.Builders;
54

6-
namespace LeaveManagement.Web.Configurations.Entities
5+
namespace LeaveManagement.Data.Configurations.Entities
76
{
87
public class UserSeedConfiguration : IEntityTypeConfiguration<Employee>
98
{

LeaveManagement.Web/Data/Employee.cs LeaveManagement.Data/Employee.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.AspNetCore.Identity;
22

3-
namespace LeaveManagement.Web.Data
3+
namespace LeaveManagement.Data
44
{
55
public class Employee: IdentityUser
66
{

LeaveManagement.Web/Data/LeaveAllocation.cs LeaveManagement.Data/LeaveAllocation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations.Schema;
22

3-
namespace LeaveManagement.Web.Data
3+
namespace LeaveManagement.Data
44
{
55
public class LeaveAllocation: BaseEntity
66
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5" />
12+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.5" />
13+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.5" />
14+
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<Folder Include="Migrations\" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<ProjectReference Include="..\LeaveManagement.Common\LeaveManagement.Common.csproj" />
23+
</ItemGroup>
24+
25+
</Project>

LeaveManagement.Web/Data/LeaveRequest.cs LeaveManagement.Data/LeaveRequest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations.Schema;
22

3-
namespace LeaveManagement.Web.Data
3+
namespace LeaveManagement.Data
44
{
55
public class LeaveRequest: BaseEntity
66
{

LeaveManagement.Web/Data/LeaveType.cs LeaveManagement.Data/LeaveType.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace LeaveManagement.Web.Data
1+
namespace LeaveManagement.Data
22
{
33
public class LeaveType: BaseEntity
44
{

0 commit comments

Comments
 (0)