Przeglądaj źródła

attendance Calc TotalHours

zinab_elgendy 2 tygodni temu
rodzic
commit
cd1639badb

+ 2 - 2
MTWorkHR.API/Controllers/UserController.cs

@@ -20,8 +20,8 @@ namespace MTWorkHR.API.Controllers
         {
             this._userService = userService;
         }
-        [HttpGet("GetAll")]
-        public async Task<ActionResult<List<UserAllDto>>> GetAll([FromQuery] UserPagingInputDto pagingInput)
+        [HttpPost("GetAll")]
+        public async Task<ActionResult<List<UserAllDto>>> GetAll([FromBody] UserPagingInputDto pagingInput)
         {
             return Ok( await _userService.GetAll(pagingInput));
         }

+ 2 - 1
MTWorkHR.API/Program.cs

@@ -112,7 +112,8 @@ app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.AP
 app.UseCors(x => x
     .AllowAnyMethod()
     .AllowAnyHeader()
-    .SetIsOriginAllowed(origin => true) // allow any origin
+    .SetIsOriginAllowed(origin => 
+    true) // allow any origin
     .AllowCredentials()); // allow credentials
 app.UseHttpsRedirection();
 app.UseAuthentication();

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

@@ -17,6 +17,7 @@ namespace MTWorkHR.Application.Models
         public string? UserName { get; set; }
         public DateTime? CheckInTime { get; set; }
         public DateTime? CheckOutTime { get; set; }
+        public double TotalHours { get; set; }
         public DateTime AttendanceDate { get; set; }
         public string? WeekDay { get; set; }
         public CheckOutEnum LeaveType { get; set; }

+ 1 - 1
MTWorkHR.Application/Dtos/User/AttendancePagingInputDto.cs

@@ -10,7 +10,7 @@ namespace MTWorkHR.Application.Models
     public class AttendancePagingInputDto : PagingInputDto, IAttendancePagingInputDto
     {
         public DateTime? SearchDate { get; set; }
-        public string? AssignedUserId { get; set; }
+        public string? UserId { get; set; }
 
 
     }

+ 3 - 3
MTWorkHR.Application/Dtos/User/UserPagingInputDto.cs

@@ -12,9 +12,9 @@ namespace MTWorkHR.Application.Models
         public long? QualificationId { get; set; }
         public long? UniversityId { get; set; }
         public long? JobTitleId { get; set; }
-        public long? IndustryId { get; set; }
-        public long? CountryId { get; set; }
-        public long? UserTypeId { get; set; }
+        public List<long>? IndustryId { get; set; }
+        public List<long>? CountryId { get; set; }
+        public List<long>? UserTypeId { get; set; }
         public bool? Employed { get; set; }
 
     }

+ 2 - 1
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -100,7 +100,8 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<MeetingUser, MeetingUserDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
             CreateMap<ProjectTeam, ProjectTeamDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
 
-            CreateMap<Attendance, AttendanceDto>().ForMember(d=> d.WeekDay , o=> o.MapFrom(s=> s.AttendanceDate.DayOfWeek)).ReverseMap()
+            CreateMap<Attendance, AttendanceDto>().ForMember(d=> d.WeekDay , o=> o.MapFrom(s=> s.AttendanceDate.DayOfWeek))
+                .ForMember(d => d.TotalHours, o => o.MapFrom(s =>(s.CheckInTime.HasValue && s.CheckOutTime.HasValue) ? (s.CheckOutTime.Value - s.CheckInTime.Value).TotalHours:0)).ReverseMap()
                 .ForMember(d => d.CreateDate, o => o.Ignore());
 
             CreateMap<OrderAllocation, OrderAllocationDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());

+ 51 - 10
MTWorkHR.Application/Services/User/AttendanceService.cs

@@ -13,6 +13,7 @@ using MTWorkHR.Application.Services.Interfaces;
 using MTWorkHR.Core.Email;
 using MTWorkHR.Core.Entities;
 using System.Linq.Dynamic.Core;
+using System.Linq;
 
 namespace MTWorkHR.Application.Services
 {
@@ -41,10 +42,25 @@ namespace MTWorkHR.Application.Services
                 var filter = PagingInputDto.Filter;
                 query = query.Where(u => u.LeaveReason!.Contains(filter) || u.UserName!.Contains(filter));
             }
-            if(PagingInputDto.SearchDate != null)
+                  
+            if (PagingInputDto.SearchDate != null)
             {
                 query = query.Where(u => u.AttendanceDate.Date == PagingInputDto.SearchDate.Value.Date);
             }
+
+            if (PagingInputDto.UserId != null)
+            {
+                query = query.Where(u => u.UserId == PagingInputDto.UserId);
+            }
+            //var dayGroupByUser = query.GroupBy(m => new { m.UserId, m.UserName, AttendanceDate = m.AttendanceDate.Date }).Select
+            //  (g => new Attendance
+            //  {
+            //      UserId = g.Key.UserId,
+            //      UserName = g.Key.UserName,
+            //      AttendanceDate = g.Key.AttendanceDate,
+            //      TotalHours = g.Sum(s => (s.CheckInTime.HasValue && s.CheckOutTime.HasValue) ? (s.CheckOutTime.Value - s.CheckInTime.Value).TotalHours : 0)
+            //  });
+
             var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
 
             var page = order.Skip((PagingInputDto.PageNumber * PagingInputDto.PageSize) - PagingInputDto.PageSize).Take(PagingInputDto.PageSize);
@@ -54,9 +70,20 @@ namespace MTWorkHR.Application.Services
             var list = MapperObject.Mapper
                 .Map<IList<AttendanceDto>>(await page.ToListAsync());
 
+            
+            //var dayGroupByUser = list.GroupBy(m => new { m.UserId,m.WeekDay, m.UserName, AttendanceDate = m.AttendanceDate.Date }).Select
+            //  (g => new AttendanceDto { 
+            //      UserId = g.Key.UserId, UserName=g.Key.UserName,
+            //      WeekDay= g.Key.WeekDay,
+            //      AttendanceDate = g.Key.AttendanceDate, 
+            //      TotalHours = g.Sum(s=> s.TotalHours) 
+            //  }).ToList();
+
+
             var response = new PagingResultDto<AttendanceDto>
             {
-                Result = list,
+                Result = list ,
+                //Result = ! string.IsNullOrEmpty( PagingInputDto.UserId ) ? list : dayGroupByUser,
                 Total = total
             };
 
@@ -65,20 +92,34 @@ namespace MTWorkHR.Application.Services
 
         public override async Task<AttendanceDto> Create(AttendanceDto input)
         {
-            var entitiy = MapperObject.Mapper.Map<Attendance>(input);
-            if (entitiy is null)
-                throw new AppException(ExceptionEnum.MapperIssue);
+            var oldEntity = await _unitOfWork.Attendance.GetAttendanceByUserId(input.UserId, input.AttendanceDate);
+            if (oldEntity is null)
+            {
+                var entitiy = MapperObject.Mapper.Map<Attendance>(input);
+                if (entitiy is null)
+                    throw new AppException(ExceptionEnum.MapperIssue);
 
-            var newEntity = await _unitOfWork.Attendance.AddAsync(entitiy);
-            var Success = await _unitOfWork.CompleteAsync();
+                var newEntity = await _unitOfWork.Attendance.AddAsync(entitiy);
+                var Success = await _unitOfWork.CompleteAsync();
+
+                var response = Mapper.MapperObject.Mapper.Map<AttendanceDto>(newEntity);
+                return response;
+            }
+            else
+            {
+                var response = Mapper.MapperObject.Mapper.Map<AttendanceDto>(oldEntity);
+                return response;
+            }
 
-            var response = Mapper.MapperObject.Mapper.Map<AttendanceDto>(newEntity);
-            return response;
         }
 
         public override async Task<AttendanceDto> Update(AttendanceDto input)
         {
-            var entity = await _unitOfWork.Attendance.GetAttendanceByUserId(input.UserId, input.AttendanceDate);
+            Attendance? entity = null;
+            if (input.Id > 0)
+                entity = await _unitOfWork.Attendance.GetByIdAsync(input.Id);
+            else
+                entity = await _unitOfWork.Attendance.GetAttendanceByUserId(input.UserId, input.AttendanceDate);
             if (entity is null)
                 throw new AppException(ExceptionEnum.RecordNotExist);
             entity.CheckOutTime = input.CheckOutTime;

+ 13 - 12
MTWorkHR.Application/Services/User/UserService.cs

@@ -178,9 +178,9 @@ namespace MTWorkHR.Application.Services
                     u.Position.Contains(filter) ||
                     u.PhoneNumber.Contains(filter));
             }
-            if (PagingInputDto.IndustryId != null)
+            if (PagingInputDto.IndustryId != null && PagingInputDto.IndustryId.Count > 0)
             {
-                query = query.Where(u => u.IndustryId == PagingInputDto.IndustryId);
+                query = query.Where(u => u.IndustryId.HasValue && PagingInputDto.IndustryId.Contains( u.IndustryId.Value ));
             }
             if (PagingInputDto.QualificationId != null)
             {
@@ -194,22 +194,23 @@ namespace MTWorkHR.Application.Services
             {
                 query = query.Where(u => u.UniversityId == PagingInputDto.UniversityId);
             }
-            if (PagingInputDto.CountryId != null)
+            if (PagingInputDto.CountryId != null && PagingInputDto.CountryId.Count > 0)
             {
-                query = query.Where(u => u.CountryId == PagingInputDto.CountryId);
+                //List<long> CountryList = PagingInputDto.CountryId.Split(",").Select(long.Parse).ToList();
+                query = query.Where(u => u.CountryId.HasValue && PagingInputDto.CountryId.Contains(u.CountryId.Value));
             }
-            if (PagingInputDto.UserTypeId != null)
+            if (PagingInputDto.UserTypeId != null && PagingInputDto.UserTypeId.Count > 0)
             {
-                query = query.Where(u => u.UserType == PagingInputDto.UserTypeId);
+                query = query.Where(u => PagingInputDto.UserTypeId.Contains(u.UserType));
             }
-            if (PagingInputDto.Employed != null && PagingInputDto.Employed == true)
+            if (PagingInputDto.Employed != null)
             {
-                query = query.Where(u => u.CompanyId != null);
-            }
-            if (PagingInputDto.Employed != null && PagingInputDto.Employed == false)
-            {
-                query = query.Where(u => u.CompanyId == null);
+                if(PagingInputDto.Employed == true)
+                    query = query.Where(u => u.CompanyId != null);
+                else 
+                    query = query.Where(u => u.CompanyId == null);
             }
+           
 
             var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
 

+ 1 - 1
MTWorkHR.Core/IDto/IAttendancePagingInputDto.cs

@@ -5,7 +5,7 @@ namespace MTWorkHR.Core.IDto
     public interface IAttendancePagingInputDto:IPagingInputDto
     {
         public DateTime? SearchDate { get; set; }
-        public string? AssignedUserId { get; set; }
+        public string? UserId { get; set; }
 
     }
 }

+ 4 - 2
MTWorkHR.Core/IDto/IUserPagingInputDto.cs

@@ -7,8 +7,10 @@ namespace MTWorkHR.Core.IDto
         public long? QualificationId { get; set; }
         public long? UniversityId { get; set; }
         public long? JobTitleId { get; set; }
-        public long? IndustryId { get; set; }
-        public long? CountryId { get; set; }
+        public List<long>? IndustryId { get; set; }
+        public List<long>? CountryId { get; set; }
+        public List<long>? UserTypeId { get; set; }
+        public bool? Employed { get; set; }
 
     }
 }

+ 39 - 39
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -34,7 +34,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("UsersId");
 
-                    b.ToTable("ApplicationRoleApplicationUser");
+                    b.ToTable("ApplicationRoleApplicationUser", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.Attendance", b =>
@@ -103,7 +103,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("CompanyId");
 
-                    b.ToTable("Attendances");
+                    b.ToTable("Attendances", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.AttendanceLog", b =>
@@ -161,7 +161,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("AttendanceLogs");
+                    b.ToTable("AttendanceLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.AuthLog", b =>
@@ -219,7 +219,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("AuthLogs");
+                    b.ToTable("AuthLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.Base.AttachmentType", b =>
@@ -246,7 +246,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("AttachmentTypes");
+                    b.ToTable("AttachmentTypes", (string)null);
 
                     b.HasData(
                         new
@@ -348,7 +348,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("CountryId");
 
-                    b.ToTable("Cities");
+                    b.ToTable("Cities", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.Company", b =>
@@ -404,7 +404,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("Companies");
+                    b.ToTable("Companies", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.CountryLookup", b =>
@@ -436,7 +436,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("CountryLookups");
+                    b.ToTable("CountryLookups", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.FileLog", b =>
@@ -494,7 +494,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("FileLogs");
+                    b.ToTable("FileLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.Industry", b =>
@@ -518,7 +518,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("Industries");
+                    b.ToTable("Industries", (string)null);
 
                     b.HasData(
                         new
@@ -844,7 +844,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("JobTitles");
+                    b.ToTable("JobTitles", (string)null);
 
                     b.HasData(
                         new
@@ -1015,7 +1015,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("LeaveTypes");
+                    b.ToTable("LeaveTypes", (string)null);
 
                     b.HasData(
                         new
@@ -1080,7 +1080,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("LoginOTPs");
+                    b.ToTable("LoginOTPs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.Meeting", b =>
@@ -1157,7 +1157,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("CompanyId");
 
-                    b.ToTable("Meetings");
+                    b.ToTable("Meetings", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.MeetingLog", b =>
@@ -1215,7 +1215,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("MeetingLogs");
+                    b.ToTable("MeetingLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.MeetingUser", b =>
@@ -1260,7 +1260,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("MeetingId");
 
-                    b.ToTable("MeetingUser");
+                    b.ToTable("MeetingUser", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.OrderAllocation", b =>
@@ -1317,7 +1317,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("OrderTypeId");
 
-                    b.ToTable("OrderAllocations");
+                    b.ToTable("OrderAllocations", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.OrderType", b =>
@@ -1342,7 +1342,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("OrderTypes");
+                    b.ToTable("OrderTypes", (string)null);
 
                     b.HasData(
                         new
@@ -1411,7 +1411,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("Permissions");
+                    b.ToTable("Permissions", (string)null);
 
                     b.HasData(
                         new
@@ -1697,7 +1697,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("CompanyId");
 
-                    b.ToTable("Projects");
+                    b.ToTable("Projects", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectTeam", b =>
@@ -1741,7 +1741,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("ProjectId");
 
-                    b.ToTable("ProjectTeam");
+                    b.ToTable("ProjectTeam", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.Qualification", b =>
@@ -1765,7 +1765,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("Qualifications");
+                    b.ToTable("Qualifications", (string)null);
 
                     b.HasData(
                         new
@@ -1843,7 +1843,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("RoleLogs");
+                    b.ToTable("RoleLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.SettingLog", b =>
@@ -1901,7 +1901,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("SettingLogs");
+                    b.ToTable("SettingLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.TaskUser", b =>
@@ -1945,7 +1945,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("TaskId");
 
-                    b.ToTable("TaskUser");
+                    b.ToTable("TaskUser", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.Team", b =>
@@ -2001,7 +2001,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("CompanyId");
 
-                    b.ToTable("Teams");
+                    b.ToTable("Teams", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.TeamLog", b =>
@@ -2059,7 +2059,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("TeamLogs");
+                    b.ToTable("TeamLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.TeamUser", b =>
@@ -2107,7 +2107,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("TeamId");
 
-                    b.ToTable("TeamUser");
+                    b.ToTable("TeamUser", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.University", b =>
@@ -2131,7 +2131,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("Universities");
+                    b.ToTable("Universities", (string)null);
 
                     b.HasData(
                         new
@@ -2235,7 +2235,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("OrderTypeId");
 
-                    b.ToTable("OrderRequests");
+                    b.ToTable("OrderRequests", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.UserLog", b =>
@@ -2293,7 +2293,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("UserLogs");
+                    b.ToTable("UserLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.UserTask", b =>
@@ -2367,7 +2367,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("StatusId");
 
-                    b.ToTable("UserTasks");
+                    b.ToTable("UserTasks", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.UserTaskAttachment", b =>
@@ -2427,7 +2427,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("TaskId");
 
-                    b.ToTable("UserTaskAttachments");
+                    b.ToTable("UserTaskAttachments", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.UserTaskHistory", b =>
@@ -2479,7 +2479,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("TaskId");
 
-                    b.ToTable("UserTaskHistories");
+                    b.ToTable("UserTaskHistories", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.UserTaskLog", b =>
@@ -2537,7 +2537,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("UserTaskLogs");
+                    b.ToTable("UserTaskLogs", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.UserTaskStatus", b =>
@@ -2561,7 +2561,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.ToTable("UserTaskStatuses");
+                    b.ToTable("UserTaskStatuses", (string)null);
 
                     b.HasData(
                         new
@@ -2901,7 +2901,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("RoleId");
 
-                    b.ToTable("RolePermissions");
+                    b.ToTable("RolePermissions", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Infrastructure.Entities.UserAddress", b =>
@@ -2956,7 +2956,7 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.HasIndex("UserId")
                         .IsUnique();
 
-                    b.ToTable("UserAddress");
+                    b.ToTable("UserAddress", (string)null);
                 });
 
             modelBuilder.Entity("MTWorkHR.Infrastructure.Entities.UserAttachment", b =>
@@ -3019,7 +3019,7 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasIndex("UserId");
 
-                    b.ToTable("UserAttachments");
+                    b.ToTable("UserAttachments", (string)null);
                 });
 
             modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>

+ 1 - 1
MTWorkHR.Infrastructure/Repositories/User/AttendanceRepository.cs

@@ -21,7 +21,7 @@ namespace MTWorkHR.Infrastructure.Repositories
         public async Task<Attendance> GetAttendanceByUserId(string userId, DateTime attendanceDate)
         {
              var result = await dbSet
-                .FirstOrDefaultAsync(x => x.UserId == userId && x.AttendanceDate.Date == attendanceDate.Date);
+                .FirstOrDefaultAsync(x => x.UserId == userId && x.AttendanceDate.Date == attendanceDate.Date && !x.CheckOutTime.HasValue);
             return result;
         }