add validation to onget

This commit is contained in:
MahanCh
2025-04-27 14:20:16 +03:30
parent a316b2a5f1
commit e2ba7d9450
10 changed files with 146 additions and 13 deletions

View File

@@ -1,4 +1,6 @@
using _0_Framework.Domain;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.EmployeeClientTemp;
namespace Company.Domain.EmployeeClientTempAgg;
@@ -8,4 +10,5 @@ public interface IEmployeeClientTempRepository : IRepository<long, EmployeeClien
EmployeeClientTemp GetByEmployeeIdAndWorkshopId(long employeeId, long commandWorkshopId);
EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId);
void Remove(EmployeeClientTemp entity);
Task<List<EmployeeClientTempViewModel>> GetByEmployeeId(long employeeId);
}

View File

@@ -16,4 +16,5 @@ public interface ILeftWorkTempRepository:IRepository<long,LeftWorkTemp>
Task<GetStartWorkTempDetails> GetStartAndLeftWorkDetails(long employeeId, long workshopId);
void Remove(LeftWorkTemp entity);
List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId);
Task<List<LeftWorkTempViewModel>> GetLeftWorkTempsByEmployeeId(long employeeId);
}

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.EmployeeClientTemp;
@@ -8,7 +10,19 @@ public interface IEmployeeClientTempApplication
OperationResult Create(CreateEmployeeClientTemp command);
EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId);
Task<List<EmployeeClientTempViewModel>> GetByEmployeeId(long employeeId);
}
public class EmployeeClientTempViewModel
{
public string EmployeeFullName { get; set; }
public long WorkshopId { get; set; }
public long EmployeeId { get; set; }
public DateTime StartWorkDate { get; set; }
public string MaritalStatus { get; set; }
}
public class EmployeeClientTempGetDetailsViewModel

View File

@@ -32,15 +32,18 @@ public interface ILeftWorkTempApplication
/// <returns></returns>
Task<OperationResult> AcceptLeftWork(AcceptLeftWorkTemp command);
Task<List<LeftWorkTempViewModel>> GetLeftWorkTempsByEmployeeId(long employeeId);
List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId);
}
public class LeftWorkTempViewModel
{
public long LeftWorkId { get; set; }
public string StartWork { get; set; }
public string LeftWork { get; set; }
public string LastDayStanding { get; set; }
public DateTime StartWork { get; set; }
public DateTime LeftWork { get; set; }
public DateTime LastDayStanding { get; set; }
public long WorkshopId { get; set; }
public long EmployeeId { get; set; }
public long JobId { get; set; }

View File

@@ -1,4 +1,6 @@
using _0_Framework.Application;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application;
using Company.Domain.EmployeeClientTempAgg;
using CompanyManagment.App.Contracts.EmployeeClientTemp;
@@ -29,4 +31,10 @@ public class EmployeeClientTempApplication : IEmployeeClientTempApplication
{
return _employeeClientTempRepository.GetDetails(employeeId, workshopId);
}
public async Task<List<EmployeeClientTempViewModel>> GetByEmployeeId(long employeeId)
{
return await _employeeClientTempRepository.GetByEmployeeId(employeeId);
}
}

View File

@@ -240,6 +240,11 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
return op.Succcedded();
}
public async Task<List<LeftWorkTempViewModel>> GetLeftWorkTempsByEmployeeId(long employeeId)
{
return await _leftWorkTempRepository.GetLeftWorkTempsByEmployeeId(employeeId);
}
public List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId)
{
return _leftWorkTempRepository.GetLeftWorksByWorkshopId(workshopId);

View File

@@ -1,8 +1,11 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.EmployeeClientTempAgg;
using CompanyManagment.App.Contracts.EmployeeClientTemp;
using Microsoft.EntityFrameworkCore;
namespace CompanyManagment.EFCore.Repository;
@@ -32,4 +35,18 @@ public class EmployeeClientTempRepository: RepositoryBase<long, EmployeeClientT
WorkshopId = x.WorkshopId
}).FirstOrDefault();
}
public async Task<List<EmployeeClientTempViewModel>> GetByEmployeeId(long employeeId)
{
return await _context.EmployeeClientTemps.Where(x => x.EmployeeId == employeeId).Select(x =>
new EmployeeClientTempViewModel()
{
EmployeeId = x.EmployeeId,
WorkshopId = x.WorkshopId,
EmployeeFullName = x.EmployeeFullName,
MaritalStatus = x.MaritalStatus,
StartWorkDate = x.StartWorkDate
}).ToListAsync();
}
}

View File

@@ -92,12 +92,28 @@ public class LeftWorkTempRepository : RepositoryBase<long, LeftWorkTemp>, ILeftW
WorkshopId = x.WorkshopId,
EmployeeId = x.EmployeeId,
JobId = x.JobId,
LastDayStanding = x.LastDayStanding.ToFarsi(),
LeftWork = x.LeftWork.ToFarsi(),
LastDayStanding = x.LastDayStanding,
LeftWork = x.LeftWork,
LeftWorkType = x.LeftWorkType,
StartWork = x.StartWork.ToFarsi()
StartWork = x.StartWork
}).ToList();
return data;
}
public async Task<List<LeftWorkTempViewModel>> GetLeftWorkTempsByEmployeeId(long employeeId)
{
return await _companyContext.LeftWorkTemps.Where(x => x.EmployeeId == employeeId).Select(x =>
new LeftWorkTempViewModel()
{
EmployeeId = x.EmployeeId,
WorkshopId = x.WorkshopId,
LeftWorkType = x.LeftWorkType,
StartWork = x.StartWork,
LeftWork = x.LeftWork,
JobId = x.JobId,
LastDayStanding = x.LastDayStanding,
LeftWorkId = x.LeftWorkId
}).ToListAsync();
}
}

View File

@@ -6,11 +6,14 @@ using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Contract;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.EmployeeChildren;
using CompanyManagment.App.Contracts.EmployeeClientTemp;
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.Error;
using CompanyManagment.App.Contracts.Job;
using CompanyManagment.App.Contracts.LeftWork;
using CompanyManagment.App.Contracts.LeftWorkInsurance;
using CompanyManagment.App.Contracts.LeftWorkTemp;
using CompanyManagment.App.Contracts.PersonnleCode;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.Authorization;
@@ -42,7 +45,9 @@ public class IndexModel : PageModel
private readonly IPersonnelCodeApplication _personnelCodeApplication;
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IWorkshopApplication _workShopApplication;
public List<CreateEmployeChildren> ChildrenList;
private readonly ILeftWorkTempApplication _leftWorkTempApplication;
private readonly IEmployeeClientTempApplication _employeeClientTempApplication;
public List<CreateEmployeChildren> ChildrenList;
public string employeeFullName;
public List<EmployeeViewModel> Employees;
public string EmployerFullName;
@@ -57,7 +62,7 @@ public class IndexModel : PageModel
ICheckoutApplication checkoutApplication, ICheckoutRepository checkoutRepository,
IWebHostEnvironment webHostEnvironment, ILeftWorkInsuranceApplication leftWorkInsuranceApplication,
ILeftWorkApplication leftWorkApplication, IPersonnelCodeApplication personnelCodeApplication,
IJobApplication jobApplication, IEmployerApplication employerApplication)
IJobApplication jobApplication, IEmployerApplication employerApplication, ILeftWorkTempApplication leftWorkTempApplication, IEmployeeClientTempApplication employeeClientTempApplication)
{
_employeeApplication = employeeApplication;
_employeeChildrenApplication = employeeChildrenApplication;
@@ -72,7 +77,9 @@ public class IndexModel : PageModel
_personnelCodeApplication = personnelCodeApplication;
_jobApplication = jobApplication;
_employerApplication = employerApplication;
_authHelper = authHelper;
_leftWorkTempApplication = leftWorkTempApplication;
_employeeClientTempApplication = employeeClientTempApplication;
_authHelper = authHelper;
}
[TempData] public string Message { get; set; }
@@ -1466,7 +1473,27 @@ public class IndexModel : PageModel
PermissionIds = permissionIds
};
return Partial("./LeftWork", command);
var leftWorks = _leftWorkTempApplication.GetLeftWorkTempsByEmployeeId(employeeId).GetAwaiter().GetResult();
if (leftWorks.Any(x => x.LeftWorkType == LeftWorkTempType.LeftWork))
{
var resultError = new ErrorViewModel()
{
Message = "این پرسنل دارای یک درخواست ترک کار میباشد لطفا اول آن را در کارپوشه خود تعیین تکلیف نمایید",
};
return Partial("../Error/_ErrorModal", resultError);
}
var clientTemps = _employeeClientTempApplication.GetByEmployeeId(employeeId).GetAwaiter().GetResult();
if (leftWorks.Any(x => x.LeftWorkType == LeftWorkTempType.StartWork) || clientTemps.Any())
{
var resultError = new ErrorViewModel()
{
Message = "این پرسنل دارای یک درخواست شروع به کار میباشد لطفا اول آن را در کارپوشه خود تعیین تکلیف نمایید",
};
return Partial("../Error/_ErrorModal", resultError);
}
return Partial("./LeftWork", command);
}
public IActionResult OnPostCreateLeftWork(LeftWorkDividedList command)

View File

@@ -0,0 +1,39 @@
@model CompanyManagment.App.Contracts.Error.ErrorViewModel
@{
<style>
.disable {
pointer-events: none;
filter: grayscale(100%);
opacity: 0.6;
}
.modal-content {
padding: 2px !important;
}
</style>
}
<div class="modal-header" style="border-bottom: unset">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h5 class="text-center" id="startBuyLabel">خطا</h5>
</div>
<div class="modal-body clearfix">
<section class="container-fluid d-flex justify-content-center align-items-center" style="height: 220px">
<div class="row justify-content-center align-items-center">
<div class="col-12 mt-2 text-center">
<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 124px;">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 12.5C4 7.80558 7.80558 4 12.5 4C17.1944 4 21 7.80558 21 12.5C21 17.1944 17.1944 21 12.5 21C7.80558 21 4 17.1944 4 12.5ZM13 14.5V16H12V14.5H13ZM12 9V13H13V9H12Z" fill="#bdbdbd"></path>
</g>
</svg>
<p class="m-0 p-2">@Model.WorkshopFullName</p>
<p>@Model.Message</p>
</div>
</div>
</section>
</div>