Browse Source

Attendance

zinab_elgendy 10 months ago
parent
commit
00c690de46
24 changed files with 2531 additions and 7 deletions
  1. 63 0
      MTWorkHR.API/Controllers/AttendanceController.cs
  2. 1 0
      MTWorkHR.Application/ApplicationServiceRegistration.cs
  3. 31 0
      MTWorkHR.Application/Dtos/Attendance/AttendanceDto.cs
  4. 23 0
      MTWorkHR.Application/Dtos/Identity/CompanyDto.cs
  5. 3 0
      MTWorkHR.Application/Mapper/MappingProfile.cs
  6. 11 0
      MTWorkHR.Application/Services/Interfaces/IAttendanceService.cs
  7. 38 0
      MTWorkHR.Application/Services/User/AttendanceService.cs
  8. 29 0
      MTWorkHR.Core/Entities/Attendance/Attendance.cs
  9. 1 2
      MTWorkHR.Core/Entities/Auth/Company.cs
  10. 39 0
      MTWorkHR.Core/Entities/Logging/AttendanceLog.cs
  11. 15 0
      MTWorkHR.Core/Global/Enum/ApprovalStatusEnum.cs
  12. 15 0
      MTWorkHR.Core/Global/Enum/LeaveTypeEnum.cs
  13. 17 0
      MTWorkHR.Core/IRepositories/User/IAttendanceRepository.cs
  14. 2 3
      MTWorkHR.Core/IRepositories/User/ITeamRepository.cs
  15. 1 0
      MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs
  16. 1 0
      MTWorkHR.Core/IUnitOfWork/IUnitOfWorkLog.cs
  17. 2 0
      MTWorkHR.Infrastructure/DBContext/HRDataContext.cs
  18. 1 0
      MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs
  19. 1968 0
      MTWorkHR.Infrastructure/Migrations/20240311151145_attendance.Designer.cs
  20. 106 0
      MTWorkHR.Infrastructure/Migrations/20240311151145_attendance.cs
  21. 132 1
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs
  22. 25 0
      MTWorkHR.Infrastructure/Repositories/User/AttendanceRepository.cs
  23. 4 1
      MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs
  24. 3 0
      MTWorkHR.Infrastructure/UnitOfWork/UnitOfWorkLog.cs

+ 63 - 0
MTWorkHR.API/Controllers/AttendanceController.cs

@@ -0,0 +1,63 @@
+using Microsoft.AspNetCore.Authorization;
+
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Identity;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Identity.Services;
+
+namespace MTWorkHR.API.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class AttendanceController : ControllerBase
+    {
+        private readonly IAttendanceService _AttendanceService;
+        public AttendanceController(IAttendanceService UserAttendanceService)
+        {
+            this._AttendanceService = UserAttendanceService;
+        }
+        [HttpGet("GetAll")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task<ActionResult<List<AttendanceDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
+        {
+            return Ok(await _AttendanceService.GetAll(pagingInput));
+        }
+        [HttpGet("Get")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task<ActionResult<AttendanceDto>> Get(long AttendanceId)
+        {
+            return Ok(await _AttendanceService.GetById(AttendanceId));
+        }
+
+
+        [HttpPost("Create")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        public async Task<ActionResult<AttendanceDto>> Create([FromBody] AttendanceDto input)
+        {
+            return await _AttendanceService.Create(input);
+        }
+
+        [HttpPost("Update")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task Update([FromBody] AttendanceDto input)
+        {
+            await _AttendanceService.Update(input);
+        }
+
+        [HttpPost("Delete")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task Delete(long id)
+        {
+            await _AttendanceService.Delete(id);
+        }
+
+
+
+    }
+}

+ 1 - 0
MTWorkHR.Application/ApplicationServiceRegistration.cs

@@ -28,6 +28,7 @@ namespace MTWorkHR.Application
             services.AddScoped<IUserTaskHistoryService, UserTaskHistoryService>();
             services.AddScoped<IUserTaskHistoryService, UserTaskHistoryService>();
             services.AddScoped<ITeamService, TeamService>();
             services.AddScoped<ITeamService, TeamService>();
             services.AddScoped<IMeetingService, MeetingService>();
             services.AddScoped<IMeetingService, MeetingService>();
+            services.AddScoped<IAttendanceService, AttendanceService>();
             
             
             return services;
             return services;
         }
         }

+ 31 - 0
MTWorkHR.Application/Dtos/Attendance/AttendanceDto.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class AttendanceDto : EntityDto
+    {
+        [Required]
+        public string UserId { get; set; }
+        public string? UserName { get; set; }
+        public DateTime? LoginTime { get; set; }
+        public DateTime? CheckInTime { get; set; }
+        public DateTime? CheckOutTime { get; set; }
+        public DateTime AttendanceDate { get; set; }
+        public string? WeekDay { get; set; }
+        public LeaveTypeEnum LeaveType { get; set; }
+
+        [MaxLength(250)]
+        public string? LeaveReason { get; set; }
+        
+
+
+    }
+}

+ 23 - 0
MTWorkHR.Application/Dtos/Identity/CompanyDto.cs

@@ -0,0 +1,23 @@
+using MTWorkHR.Core.Global;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Models
+{
+    public class CompanyDto : EntityDto
+    {
+        public long UserId { get; set; }
+
+        public string CompanyName { get; set; }
+
+        public string CRNumber { get; set; }
+        public int TaxNumber { get; set; }
+
+        public UserDto CompanyUser { get; set; }
+       
+    }
+}

+ 3 - 0
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -68,6 +68,9 @@ namespace MTWorkHR.Application.Mapper
                 .ForMember(d => d.CreateDate, o => o.Ignore());
                 .ForMember(d => d.CreateDate, o => o.Ignore());
             CreateMap<MeetingUser, MeetingUserDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
             CreateMap<MeetingUser, MeetingUserDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
 
 
+            CreateMap<Attendance, AttendanceDto>().ReverseMap()
+                .ForMember(d => d.CreateDate, o => o.Ignore());
+
 
 
 
 
         }
         }

+ 11 - 0
MTWorkHR.Application/Services/Interfaces/IAttendanceService.cs

@@ -0,0 +1,11 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Services.Interfaces
+{
+    public interface IAttendanceService : IService<Attendance, AttendanceDto, AttendanceDto>
+    {
+    }
+}

+ 38 - 0
MTWorkHR.Application/Services/User/AttendanceService.cs

@@ -0,0 +1,38 @@
+using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.WebUtilities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using MTWorkHR.Application.Identity;
+using MTWorkHR.Application.Mapper;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Global;
+using MTWorkHR.Core.IRepositories;
+using MTWorkHR.Core.UnitOfWork;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Core.Email;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Infrastructure.UnitOfWorks;
+
+namespace MTWorkHR.Application.Services
+{
+    public class AttendanceService : BaseService<Attendance, AttendanceDto, AttendanceDto>, IAttendanceService
+    {
+        private readonly IUnitOfWork _unitOfWork;
+
+        public AttendanceService(IUnitOfWork unitOfWork):base(unitOfWork)
+        {
+            _unitOfWork = unitOfWork;
+        }
+
+        public override async Task<AttendanceDto> GetById(long id)
+        {
+            var entity = await _unitOfWork.Attendance.GetByIdWithAllChildren(id);
+            var response = MapperObject.Mapper.Map<AttendanceDto>(entity);
+            return response;
+        }
+
+
+
+    }
+}

+ 29 - 0
MTWorkHR.Core/Entities/Attendance/Attendance.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class Attendance : FullAuditEntity
+    {
+        [Required]
+        public string UserId { get; set; }
+        public string? UserName { get; set; }
+        public DateTime? LoginTime { get; set; }
+        public DateTime? CheckInTime { get; set; }
+        public DateTime? CheckOutTime { get; set; }
+        public DateTime AttendanceDate { get; set; }
+        public LeaveTypeEnum LeaveType { get; set; }
+
+        [MaxLength(250)]
+        public string? LeaveReason { get; set; }
+        
+
+
+    }
+}

+ 1 - 2
MTWorkHR.Core/Entities/Auth/Company.cs

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
 
 
 namespace MTWorkHR.Core.Entities
 namespace MTWorkHR.Core.Entities
 {
 {
-    public class Company : AuditEntity
+    public class Company : FullAuditEntity
     {
     {
         public long UserId { get; set; }
         public long UserId { get; set; }
 
 
@@ -16,6 +16,5 @@ namespace MTWorkHR.Core.Entities
 
 
         public string CRNumber { get; set; }
         public string CRNumber { get; set; }
         public int TaxNumber { get; set; }
         public int TaxNumber { get; set; }
-        public bool IsDeleted { get; set; }
     }
     }
 }
 }

+ 39 - 0
MTWorkHR.Core/Entities/Logging/AttendanceLog.cs

@@ -0,0 +1,39 @@
+using System;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class AttendanceLog : Log
+    {
+        public AttendanceLog():base()
+        {
+
+        }
+        public AttendanceLog(string Method
+            , string QueryString
+            , string Input
+            , DateTime CreateDate
+            , string CreateUser
+            , string ServerIP
+            , string Channel
+            , string UserIP
+            , string ServiceResponseTimeInSeconds
+            , string ErrorCode
+            , string ErrorDescription
+            , string InnerException
+            ) : base(Method
+                , QueryString
+                , Input
+                , CreateDate
+                , CreateUser
+                , ServerIP
+                , Channel
+                , UserIP
+                , ServiceResponseTimeInSeconds
+                , ErrorCode
+                , ErrorDescription
+                , InnerException)
+        {
+            //
+        }
+    }
+}

+ 15 - 0
MTWorkHR.Core/Global/Enum/ApprovalStatusEnum.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum ApprovalStatusEnum
+    {
+        Pending = 1,
+        Approved = 2,
+        Rejected = 3,
+    }
+}

+ 15 - 0
MTWorkHR.Core/Global/Enum/LeaveTypeEnum.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum LeaveTypeEnum
+    {
+        Leave = 1,
+        Meeting = 2,
+        Other = 3,
+    }
+}

+ 17 - 0
MTWorkHR.Core/IRepositories/User/IAttendanceRepository.cs

@@ -0,0 +1,17 @@
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IRepositories.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.IRepositories
+{
+    public interface ITeamRepository : IRepository<Team>
+    {
+        Task<Team> GetByIdWithAllChildren(long id);
+     //   Task<bool> AssignAdminManager(string userId, long teamId, bool isAdmin);
+
+    }
+}

+ 2 - 3
MTWorkHR.Core/IRepositories/User/ITeamRepository.cs

@@ -8,10 +8,9 @@ using System.Threading.Tasks;
 
 
 namespace MTWorkHR.Core.IRepositories
 namespace MTWorkHR.Core.IRepositories
 {
 {
-    public interface ITeamRepository : IRepository<Team>
+    public interface IAttendanceRepository : IRepository<Attendance>
     {
     {
-        Task<Team> GetByIdWithAllChildren(long id);
-     //   Task<bool> AssignAdminManager(string userId, long teamId, bool isAdmin);
+        Task<Attendance> GetByIdWithAllChildren(long id);
 
 
     }
     }
 }
 }

+ 1 - 0
MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs

@@ -17,6 +17,7 @@ namespace MTWorkHR.Core.UnitOfWork
         ICompanyRepository Company { get; }
         ICompanyRepository Company { get; }
         ITeamRepository Team{ get; }
         ITeamRepository Team{ get; }
         IMeetingRepository Meeting{ get; }
         IMeetingRepository Meeting{ get; }
+        IAttendanceRepository Attendance { get; }
         Task<int> CompleteAsync();
         Task<int> CompleteAsync();
 
 
         void BeginTran();
         void BeginTran();

+ 1 - 0
MTWorkHR.Core/IUnitOfWork/IUnitOfWorkLog.cs

@@ -14,6 +14,7 @@ namespace MTWorkHR.Core.UnitOfWork
         IRepositoryLog<FileLog> FileLog { get; }
         IRepositoryLog<FileLog> FileLog { get; }
         IRepositoryLog<RoleLog> RoleLog { get; }
         IRepositoryLog<RoleLog> RoleLog { get; }
         IRepositoryLog<UserTaskLog> UserTaskLog { get; }
         IRepositoryLog<UserTaskLog> UserTaskLog { get; }
+        IRepositoryLog<AttendanceLog> AttendanceLog { get; }
 
 
 
 
 		Task<int> CompleteAsync();
 		Task<int> CompleteAsync();

+ 2 - 0
MTWorkHR.Infrastructure/DBContext/HRDataContext.cs

@@ -35,6 +35,7 @@ namespace MTWorkHR.Infrastructure.DBContext
         public DbSet<UserTaskHistory> UserTaskHistories { get; set; }
         public DbSet<UserTaskHistory> UserTaskHistories { get; set; }
         public DbSet<Team> Teams { get; set; }
         public DbSet<Team> Teams { get; set; }
         public DbSet<Meeting> Meetings { get; set; }
         public DbSet<Meeting> Meetings { get; set; }
+        public DbSet<Attendance> Attendances { get; set; }
         //------------------------Logs------------------------
         //------------------------Logs------------------------
         public DbSet<UserLog> UserLogs { get; set; }
         public DbSet<UserLog> UserLogs { get; set; }
         public DbSet<AuthLog> AuthLogs { get; set; }
         public DbSet<AuthLog> AuthLogs { get; set; }
@@ -44,6 +45,7 @@ namespace MTWorkHR.Infrastructure.DBContext
         public DbSet<UserTaskLog> UserTaskLogs { get; set; }
         public DbSet<UserTaskLog> UserTaskLogs { get; set; }
         public DbSet<TeamLog> TeamLogs { get; set; }
         public DbSet<TeamLog> TeamLogs { get; set; }
         public DbSet<MeetingLog> MeetingLogs { get; set; }
         public DbSet<MeetingLog> MeetingLogs { get; set; }
+        public DbSet<AttendanceLog> AttendanceLogs { get; set; }
         //----------------------------------------
         //----------------------------------------
         protected override void OnModelCreating(ModelBuilder builder)
         protected override void OnModelCreating(ModelBuilder builder)
         {
         {

+ 1 - 0
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -67,6 +67,7 @@ namespace MTWorkHR.Infrastructure
             
             
             services.AddScoped(typeof(ITeamRepository), typeof(TeamRepository));
             services.AddScoped(typeof(ITeamRepository), typeof(TeamRepository));
             services.AddScoped(typeof(IMeetingRepository), typeof(MeetingRepository));
             services.AddScoped(typeof(IMeetingRepository), typeof(MeetingRepository));
+            services.AddScoped(typeof(IAttendanceRepository), typeof(AttendanceRepository));
 
 
 
 
 
 

File diff suppressed because it is too large
+ 1968 - 0
MTWorkHR.Infrastructure/Migrations/20240311151145_attendance.Designer.cs


+ 106 - 0
MTWorkHR.Infrastructure/Migrations/20240311151145_attendance.cs

@@ -0,0 +1,106 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class attendance : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AlterColumn<bool>(
+                name: "IsDeleted",
+                table: "Companies",
+                type: "bit",
+                nullable: false,
+                oldClrType: typeof(bool),
+                oldType: "bit")
+                .Annotation("Relational:ColumnOrder", 7);
+
+            migrationBuilder.AddColumn<string>(
+                name: "DeleteUserId",
+                table: "Companies",
+                type: "nvarchar(450)",
+                maxLength: 450,
+                nullable: true)
+                .Annotation("Relational:ColumnOrder", 8);
+
+            migrationBuilder.CreateTable(
+                name: "AttendanceLogs",
+                columns: table => new
+                {
+                    Id = table.Column<long>(type: "bigint", nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    Method = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    QueryString = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    Input = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
+                    CreateUser = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    ServerIP = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    Channel = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    UserIP = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    ServiceResponseTimeInSeconds = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    ErrorCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    ErrorDescription = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    InnerException = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    userAgent = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_AttendanceLogs", x => x.Id);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "Attendances",
+                columns: table => new
+                {
+                    Id = table.Column<long>(type: "bigint", nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
+                    UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
+                    DeleteUserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    UserId = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    UserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    LoginTime = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    CheckInTime = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    CheckOutTime = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    AttendanceDate = table.Column<DateTime>(type: "datetime2", nullable: false),
+                    LeaveType = table.Column<int>(type: "int", nullable: false),
+                    LeaveReason = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_Attendances", x => x.Id);
+                });
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropTable(
+                name: "AttendanceLogs");
+
+            migrationBuilder.DropTable(
+                name: "Attendances");
+
+            migrationBuilder.DropColumn(
+                name: "DeleteUserId",
+                table: "Companies");
+
+            migrationBuilder.AlterColumn<bool>(
+                name: "IsDeleted",
+                table: "Companies",
+                type: "bit",
+                nullable: false,
+                oldClrType: typeof(bool),
+                oldType: "bit")
+                .OldAnnotation("Relational:ColumnOrder", 7);
+        }
+    }
+}

+ 132 - 1
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -37,6 +37,131 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.ToTable("ApplicationRoleApplicationUser");
                     b.ToTable("ApplicationRoleApplicationUser");
                 });
                 });
 
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.Attendance", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<DateTime>("AttendanceDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<DateTime?>("CheckInTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<DateTime?>("CheckOutTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<string>("DeleteUserId")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(8);
+
+                    b.Property<bool>("IsDeleted")
+                        .HasColumnType("bit")
+                        .HasColumnOrder(7);
+
+                    b.Property<string>("LeaveReason")
+                        .HasMaxLength(250)
+                        .HasColumnType("nvarchar(250)");
+
+                    b.Property<int>("LeaveType")
+                        .HasColumnType("int");
+
+                    b.Property<DateTime?>("LoginTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.Property<string>("UserId")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("UserName")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("Id");
+
+                    b.ToTable("Attendances");
+                });
+
+            modelBuilder.Entity("MTWorkHR.Core.Entities.AttendanceLog", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<string>("Channel")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("CreateUser")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("ErrorCode")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("ErrorDescription")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("InnerException")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Input")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Method")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("QueryString")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("ServerIP")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("ServiceResponseTimeInSeconds")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("UserIP")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("userAgent")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("Id");
+
+                    b.ToTable("AttendanceLogs");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.AuthLog", b =>
             modelBuilder.Entity("MTWorkHR.Core.Entities.AuthLog", b =>
                 {
                 {
                     b.Property<long>("Id")
                     b.Property<long>("Id")
@@ -164,8 +289,14 @@ namespace MTWorkHR.Infrastructure.Migrations
                         .HasColumnType("nvarchar(450)")
                         .HasColumnType("nvarchar(450)")
                         .HasColumnOrder(1);
                         .HasColumnOrder(1);
 
 
+                    b.Property<string>("DeleteUserId")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(8);
+
                     b.Property<bool>("IsDeleted")
                     b.Property<bool>("IsDeleted")
-                        .HasColumnType("bit");
+                        .HasColumnType("bit")
+                        .HasColumnOrder(7);
 
 
                     b.Property<int>("TaxNumber")
                     b.Property<int>("TaxNumber")
                         .HasColumnType("int");
                         .HasColumnType("int");

+ 25 - 0
MTWorkHR.Infrastructure/Repositories/User/AttendanceRepository.cs

@@ -0,0 +1,25 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Core.IRepositories;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.DBContext;
+
+namespace MTWorkHR.Infrastructure.Repositories
+{
+    public class AttendanceRepository : Repository<Attendance>, IAttendanceRepository
+    {
+        private readonly DbSet<Attendance> dbSet;
+
+        public AttendanceRepository(HRDataContext context) : base(context)
+        {
+            dbSet = context.Set<Attendance>();
+
+        }
+        public async Task<Attendance> GetByIdWithAllChildren(long id)
+        {
+            return await dbSet
+                .FirstOrDefaultAsync(x => x.Id == id);
+        }
+    }
+}

+ 4 - 1
MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

@@ -23,6 +23,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
         public IProjectRepository Project { get; }
         public IProjectRepository Project { get; }
         public ITeamRepository Team{ get; }
         public ITeamRepository Team{ get; }
         public IMeetingRepository Meeting{ get; }
         public IMeetingRepository Meeting{ get; }
+        public IAttendanceRepository Attendance { get; }
 
 
         public UnitOfWork(HRDataContext _context
         public UnitOfWork(HRDataContext _context
             , IPermissionRepository permission
             , IPermissionRepository permission
@@ -31,9 +32,10 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             , IProjectRepository project
             , IProjectRepository project
             , IUserTaskHistoryRepository projectHistory
             , IUserTaskHistoryRepository projectHistory
             , ITaskStatusRepository userTaskStatus
             , ITaskStatusRepository userTaskStatus
-            ,IUserTaskAttachmentRepository userTaskAttachment
+            , IUserTaskAttachmentRepository userTaskAttachment
             , ITeamRepository teamRepository
             , ITeamRepository teamRepository
             , IMeetingRepository meetingRepository
             , IMeetingRepository meetingRepository
+            , IAttendanceRepository attendance
             )
             )
         {
         {
             context = _context;
             context = _context;
@@ -46,6 +48,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             this.UserTaskAttachment = userTaskAttachment;
             this.UserTaskAttachment = userTaskAttachment;
             this.Team = teamRepository;
             this.Team = teamRepository;
             this.Meeting = meetingRepository;
             this.Meeting = meetingRepository;
+            Attendance = attendance;
         }
         }
 
 
         public async Task<int> CompleteAsync()
         public async Task<int> CompleteAsync()

+ 3 - 0
MTWorkHR.Infrastructure/UnitOfWork/UnitOfWorkLog.cs

@@ -22,6 +22,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
         public IRepositoryLog<UserTaskLog> UserTaskLog { get; }
         public IRepositoryLog<UserTaskLog> UserTaskLog { get; }
         public IRepositoryLog<TeamLog> TeamLog { get; }
         public IRepositoryLog<TeamLog> TeamLog { get; }
         public IRepositoryLog<MeetingLog> MeetingLog { get; }
         public IRepositoryLog<MeetingLog> MeetingLog { get; }
+        public IRepositoryLog<AttendanceLog> AttendanceLog { get; }
 
 
 
 
         public UnitOfWorkLog(HRDataContext _context
         public UnitOfWorkLog(HRDataContext _context
@@ -33,6 +34,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             , IRepositoryLog<UserTaskLog> userTaskLog
             , IRepositoryLog<UserTaskLog> userTaskLog
             , IRepositoryLog<TeamLog> teamLog
             , IRepositoryLog<TeamLog> teamLog
             , IRepositoryLog<MeetingLog> meetingLog
             , IRepositoryLog<MeetingLog> meetingLog
+            , IRepositoryLog<AttendanceLog> attendanceLog
             )
             )
         {
         {
             context = _context;
             context = _context;
@@ -45,6 +47,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             this.UserTaskLog = userTaskLog;
             this.UserTaskLog = userTaskLog;
             this.TeamLog = teamLog;
             this.TeamLog = teamLog;
             this.MeetingLog = meetingLog;
             this.MeetingLog = meetingLog;
+            this.AttendanceLog = attendanceLog;
 		}
 		}
 
 
         public async Task<int> CompleteAsync()
         public async Task<int> CompleteAsync()