Duplicate LeftWorkTemp Bug Fixed
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
@@ -14,4 +15,5 @@ public interface ILeftWorkTempRepository:IRepository<long,LeftWorkTemp>
|
||||
/// <returns></returns>
|
||||
Task<GetStartWorkTempDetails> GetStartAndLeftWorkDetails(long employeeId, long workshopId);
|
||||
void Remove(LeftWorkTemp entity);
|
||||
List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
@@ -30,6 +31,20 @@ public interface ILeftWorkTempApplication
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> AcceptLeftWork(AcceptLeftWorkTemp command);
|
||||
|
||||
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 long WorkshopId { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public long JobId { get; set; }
|
||||
public LeftWorkTempType LeftWorkType { get; set; }
|
||||
}
|
||||
|
||||
public class AcceptLeftWorkTemp
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
@@ -57,6 +58,11 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
|
||||
{
|
||||
#region Validation
|
||||
|
||||
if (_leftWorkTempRepository.Exists(x=>x.WorkshopId == command.WorkshopId && x.EmployeeId == employeeId))
|
||||
{
|
||||
return op.Failed("برای پرسنل وارد شده قبلا درخواست ترک کار ثبت کرده اید");
|
||||
}
|
||||
|
||||
if (command.LeftWorkTime.TryToGeorgianDateTime(out var leftWorkDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
|
||||
@@ -233,6 +239,13 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId)
|
||||
{
|
||||
return _leftWorkTempRepository.GetLeftWorksByWorkshopId(workshopId);
|
||||
|
||||
}
|
||||
|
||||
//این متد ترک کار های کارمند را با فعالیت حضور غیاب یکپارچه می کند
|
||||
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading.Tasks;
|
||||
@@ -7,6 +9,7 @@ using _0_Framework.InfraStructure;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.LeftWorkTempAgg;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
|
||||
|
||||
@@ -36,19 +39,19 @@ public class LeftWorkTempRepository : RepositoryBase<long, LeftWorkTemp>, ILeftW
|
||||
}
|
||||
|
||||
var job = await _companyContext.Jobs.FindAsync(leftWorkTemp.JobId);
|
||||
|
||||
|
||||
|
||||
var previousLeftWorks = _companyContext.LeftWorkList
|
||||
.Where(x => leftWorkTemp.EmployeeId == x.EmployeeId && leftWorkTemp.WorkshopId == x.WorkshopId).ToList();
|
||||
|
||||
|
||||
|
||||
if (leftWorkTemp.LeftWorkType == LeftWorkTempType.LeftWork)
|
||||
{
|
||||
previousLeftWorks = previousLeftWorks.Where(x => x.id != leftWorkTemp.LeftWorkId).ToList();
|
||||
|
||||
|
||||
}
|
||||
if (leftWorkTemp.LeftWorkType == LeftWorkTempType.LeftWork)
|
||||
{
|
||||
previousLeftWorks = previousLeftWorks.Where(x => x.id != leftWorkTemp.LeftWorkId).ToList();
|
||||
|
||||
|
||||
}
|
||||
|
||||
var personnelCode =
|
||||
_companyContext.PersonnelCodeSet.FirstOrDefault(x =>
|
||||
@@ -79,4 +82,22 @@ public class LeftWorkTempRepository : RepositoryBase<long, LeftWorkTemp>, ILeftW
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId)
|
||||
{
|
||||
var data = _companyContext.LeftWorkTemps.Where(x => x.WorkshopId == workshopId)
|
||||
.Select(x => new LeftWorkTempViewModel
|
||||
{
|
||||
LeftWorkId = x.LeftWorkId,
|
||||
WorkshopId = x.WorkshopId,
|
||||
EmployeeId = x.EmployeeId,
|
||||
JobId = x.JobId,
|
||||
LastDayStanding = x.LastDayStanding.ToFarsi(),
|
||||
LeftWork = x.LeftWork.ToFarsi(),
|
||||
LeftWorkType = x.LeftWorkType,
|
||||
StartWork = x.StartWork.ToFarsi()
|
||||
}).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -294,6 +294,20 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetEmployeeListLeftWorkTemp()
|
||||
{
|
||||
var exists = _leftWorkTempApplication.GetLeftWorksByWorkshopId(_workshopId);
|
||||
|
||||
var employees = (await _employeeApplication.WorkedEmployeesInWorkshopSelectList(_workshopId))
|
||||
.Where(x=> exists.All(a => a.EmployeeId != x.Id)).ToList();
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = true,
|
||||
data = employees
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostCreateEmployeeLeftWork(CreateLeftWorkTemp command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
<script src="~/assetsclient/libs/wordifyfa/wordifyfa.min.js"></script>
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var employeeListAjax = `@Url.Page("./EmployeeList", "EmployeeList")`; // EmployeeList Handler
|
||||
var employeeListAjax = `@Url.Page("./EmployeeList", "EmployeeListLeftWorkTemp")`; // EmployeeList Handler
|
||||
var dayOfWeekDataUrl = `@Url.Page("./EmployeeList", "DayOfWeek")`; // EmployeeList Handler
|
||||
var saveLeftWorkAjax = `@Url.Page("./EmployeeList", "CreateEmployeeLeftWork")`; // EmployeeList Handler
|
||||
|
||||
|
||||
@@ -583,7 +583,10 @@ namespace ServiceHost.Areas.Client.Pages
|
||||
{
|
||||
var workshopSlug = User.FindFirst("WorkshopSlug")?.Value;
|
||||
long workshopIDecrypt = _passwordHasher.SlugDecrypt(workshopSlug);
|
||||
var employees = await _employeeApplication.WorkedEmployeesInWorkshopSelectList(workshopIDecrypt);
|
||||
var exists = _leftWorkTempApplication.GetLeftWorksByWorkshopId(workshopIDecrypt);
|
||||
|
||||
var employees = (await _employeeApplication.WorkedEmployeesInWorkshopSelectList(workshopIDecrypt))
|
||||
.Where(x => exists.All(a => a.EmployeeId != x.Id)).ToList();
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user