cameraDirectLogin from admin - fix bug at GetWorkshopAbsentHistory
This commit is contained in:
@@ -52,5 +52,7 @@ public interface IAccountApplication
|
||||
OperationResult IsPhoneNumberAndPasswordValid(long accountId, string phoneNumber, string password, string rePassword);
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
OperationResult DirectCameraLogin(long cameraAccountId);
|
||||
}
|
||||
@@ -477,7 +477,7 @@ public class AccountApplication : IAccountApplication
|
||||
var operation = new OperationResult();
|
||||
var account = _accountRepository.GetById(id);
|
||||
if (account == null)
|
||||
return operation.Failed("این اکان وجود ندارد");
|
||||
return operation.Failed("این اکانت وجود ندارد");
|
||||
|
||||
|
||||
|
||||
@@ -510,8 +510,37 @@ public class AccountApplication : IAccountApplication
|
||||
_authHelper.Signin(authViewModel);
|
||||
return operation.Succcedded(2);
|
||||
}
|
||||
public OperationResult DirectCameraLogin(long cameraAccountId)
|
||||
{
|
||||
var prAcc = _authHelper.CurrentAccountInfo();
|
||||
var operation = new OperationResult();
|
||||
var cameraAccount = _cameraAccountRepository.GetById(cameraAccountId);
|
||||
if (cameraAccount == null)
|
||||
return operation.Failed("این اکانت وجود ندارد");
|
||||
|
||||
public AccountLeftWorkViewModel WorkshopList(long accountId)
|
||||
|
||||
|
||||
|
||||
|
||||
_authHelper.SignOut();
|
||||
|
||||
|
||||
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
|
||||
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
|
||||
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId, cameraAccount.IsActiveSting);
|
||||
if (cameraAccount.IsActiveSting == "true")
|
||||
{
|
||||
_authHelper.CameraSignIn(authViewModel);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return operation.Failed("این اکانت غیر فعال شده است");
|
||||
}
|
||||
return operation.Succcedded(2);
|
||||
}
|
||||
|
||||
public AccountLeftWorkViewModel WorkshopList(long accountId)
|
||||
{
|
||||
string fullname = this._accountRepository.GetById(accountId).Fullname;
|
||||
List<WorkshopAccountlistViewModel> source =_accountLeftworkRepository.WorkshopList(accountId);
|
||||
|
||||
@@ -13,10 +13,11 @@ public interface ILeaveRepository : IRepository<long, Leave>
|
||||
OperationResult RemoveLeave(long id);
|
||||
|
||||
#region Pooya
|
||||
List<LeaveViewModel> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime start, DateTime end);
|
||||
/// <summary>
|
||||
/// چک می کند که آیا پرسنل مرخصی روزانه استحقاقی دارد یا خیر
|
||||
/// </summary>
|
||||
bool HasLeave(long employeeId, long workshopId, DateTime date);
|
||||
bool HasDailyLeave(long employeeId, long workshopId, DateTime date);
|
||||
#endregion
|
||||
|
||||
bool CheckContractExist(DateTime myDate,long employeeId, long workshopId);
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Company.Domain.RollCallAgg
|
||||
#region Pooya
|
||||
List<RollCallsByDateViewModel> GetWorkshopAbsentHistory(long workshopId, DateTime startSearch,
|
||||
DateTime endSearch);
|
||||
List<RollCallViewModel> GetEmployeeRollCallsHistoryAllByDate(long workshopId, long employeeId, DateTime start, DateTime end);
|
||||
void RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, DateTime date);
|
||||
RollCallsByDateViewModel GetWorkshopRollCallHistory(RollCallSearchModel searchModel);
|
||||
CurrentDayRollCall GetWorkshopCurrentDayRollCalls(long workshopId);
|
||||
|
||||
@@ -26,5 +26,10 @@ public interface ILeaveApplication
|
||||
|
||||
#endregion
|
||||
bool CheckIfValidToEdit(long id);
|
||||
OperationResult<bool> HasLeave(long workshopId, long employeeId, string dateFa);
|
||||
OperationResult<bool> HasDailyLeave(long workshopId, long employeeId, string dateFa);
|
||||
|
||||
#region Pooya
|
||||
OperationResult ValidateNewLeaveWithExistingRollCalls(long workshopId, long employeeId, string paidLeaveType, DateTime start, DateTime end);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -72,12 +72,12 @@ public class LeaveApplication : ILeaveApplication
|
||||
|
||||
var start = command.StartLeave.ToGeorgianDateTime();
|
||||
|
||||
var end = command.PaidLeaveType == "ساعتی"? start : command.EndLeave.ToGeorgianDateTime();
|
||||
var end = command.PaidLeaveType == "ساعتی" ? start : command.EndLeave.ToGeorgianDateTime();
|
||||
|
||||
var checkErr = _leaveRepository.CheckErrors(start, end, command.EmployeeId, command.WorkshopId);
|
||||
|
||||
// start = new DateTime(start.Year, start.Month, start.Day, startH.Hours, startH.Minutes, startH.Seconds);
|
||||
//end = new DateTime(end.Year, end.Month, end.Day, endH.Hours, endH.Minutes, endH.Seconds);
|
||||
|
||||
// start = new DateTime(start.Year, start.Month, start.Day, startH.Hours, startH.Minutes, startH.Seconds);
|
||||
//end = new DateTime(end.Year, end.Month, end.Day, endH.Hours, endH.Minutes, endH.Seconds);
|
||||
|
||||
|
||||
if (checkErr.HasChekout)
|
||||
@@ -89,8 +89,8 @@ public class LeaveApplication : ILeaveApplication
|
||||
|
||||
if (start > end)
|
||||
return op.Failed("تارخ شروع از پایان بزرگتر است");
|
||||
|
||||
|
||||
|
||||
|
||||
var totalhourses = "-";
|
||||
if (command.LeaveType == "استحقاقی" && command.PaidLeaveType == "ساعتی")
|
||||
{
|
||||
@@ -100,7 +100,7 @@ public class LeaveApplication : ILeaveApplication
|
||||
if (start > end)
|
||||
end = end.AddDays(1);
|
||||
|
||||
var totalLeavHourses = (end - start);
|
||||
var totalLeavHourses = (end - start);
|
||||
var h = totalLeavHourses.Hours < 10 ? $"0{totalLeavHourses.Hours}" : $"{totalLeavHourses.Hours}";
|
||||
var m = totalLeavHourses.Minutes < 10 ? $"0{totalLeavHourses.Minutes}" : $"{totalLeavHourses.Minutes}";
|
||||
totalhourses = $"{h}:{m}";
|
||||
@@ -112,14 +112,14 @@ public class LeaveApplication : ILeaveApplication
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("برای ساعت پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
|
||||
var end24 = endH.Hours == 0 && endH.Minutes == 0 ? end.AddDays(-1) : end;
|
||||
if (_leaveRepository.Exists(x =>
|
||||
(x.StartLeave.Date == start.Date || x.EndLeave.Date == end24.Date) && (x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه")))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
}
|
||||
(x.StartLeave.Date == start.Date || x.EndLeave.Date == end24.Date) && (x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه")))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
}
|
||||
else if (command.LeaveType == "استحقاقی" && command.PaidLeaveType == "روزانه")
|
||||
{
|
||||
var totalLeavHourses = (end - start).TotalDays + 1;
|
||||
@@ -131,9 +131,9 @@ public class LeaveApplication : ILeaveApplication
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
}
|
||||
@@ -143,29 +143,31 @@ public class LeaveApplication : ILeaveApplication
|
||||
var totalLeavHourses = (end - start).TotalDays + 1;
|
||||
totalhourses = $"{(int)totalLeavHourses}";
|
||||
command.PaidLeaveType = "روزانه";
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
}
|
||||
|
||||
var year = Convert.ToInt32(command.StartLeave.Substring(0, 4));
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
}
|
||||
|
||||
var year = Convert.ToInt32(command.StartLeave.Substring(0, 4));
|
||||
var month = Convert.ToInt32(command.StartLeave.Substring(5, 2));
|
||||
// var checkIfHasRollCall =ValidateNewLeaveWithExistingRollCalls(command.WorkshopId, command.EmployeeId, start, end);
|
||||
//if (!checkIfHasRollCall.IsSuccedded)
|
||||
// return checkIfHasRollCall;
|
||||
var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
|
||||
|
||||
var validation = ValidateNewLeaveWithExistingRollCalls(command.WorkshopId, command.EmployeeId, command.PaidLeaveType, start, end);
|
||||
if (validation.IsSuccedded == false)
|
||||
return validation;
|
||||
|
||||
var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
|
||||
var workshopName = _workshopRepository.GetDetails(command.WorkshopId).WorkshopName;
|
||||
var leave = new Leave(start,end,totalhourses,command.WorkshopId,command.EmployeeId
|
||||
,command.PaidLeaveType,command.LeaveType,employeeFullName,workshopName, command.IsAccepted, command.Decription, year, month);
|
||||
var leave = new Leave(start, end, totalhourses, command.WorkshopId, command.EmployeeId
|
||||
, command.PaidLeaveType, command.LeaveType, employeeFullName, workshopName, command.IsAccepted, command.Decription, year, month);
|
||||
_leaveRepository.Create(leave);
|
||||
_leaveRepository.SaveChanges();
|
||||
|
||||
@@ -182,37 +184,37 @@ public class LeaveApplication : ILeaveApplication
|
||||
if (leave == null)
|
||||
op.Failed("رکورد مورد نظر وجود ندارد");
|
||||
|
||||
if (command.PaidLeaveType == "روزانه")
|
||||
if (command.PaidLeaveType == "روزانه")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command.EndLeave))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command.EndLeave))
|
||||
{
|
||||
return op.Failed("لطفا تاریخ پایان را وارد کنید");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.StartLeave))
|
||||
{
|
||||
return op.Failed("لطفا تاریخ شروع را وارد کنید");
|
||||
}
|
||||
return op.Failed("لطفا تاریخ پایان را وارد کنید");
|
||||
}
|
||||
else if (command.PaidLeaveType == "ساعتی")
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.StartLeave))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command.StartLeave))
|
||||
return op.Failed("لطفا تاریخ شروع را وارد کنید");
|
||||
if (string.IsNullOrWhiteSpace(command.StartHoures) || string.IsNullOrWhiteSpace(command.EndHours))
|
||||
return op.Failed("ساعت شروع و پایان نمیتواند خالی باشد");
|
||||
|
||||
string pattern = @"^([01]\d|2[0-3]):[0-5]\d$";
|
||||
if (!Regex.IsMatch(command.StartHoures, pattern))
|
||||
return op.Failed("لطفا ساعت شروع را به درستی وارد کنید");
|
||||
|
||||
if (!Regex.IsMatch(command.EndHours, pattern))
|
||||
return op.Failed("لطفا ساعت پایان را به درستی وارد کنید");
|
||||
|
||||
startH = TimeSpan.Parse(command.StartHoures);
|
||||
endH = TimeSpan.Parse(command.EndHours);
|
||||
if (startH == endH)
|
||||
return op.Failed("ساعت شروع و پایان نباید برابر باشد");
|
||||
return op.Failed("لطفا تاریخ شروع را وارد کنید");
|
||||
}
|
||||
}
|
||||
else if (command.PaidLeaveType == "ساعتی")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command.StartLeave))
|
||||
return op.Failed("لطفا تاریخ شروع را وارد کنید");
|
||||
if (string.IsNullOrWhiteSpace(command.StartHoures) || string.IsNullOrWhiteSpace(command.EndHours))
|
||||
return op.Failed("ساعت شروع و پایان نمیتواند خالی باشد");
|
||||
string pattern = @"^([01]\d|2[0-3]):[0-5]\d$";
|
||||
|
||||
if (!Regex.IsMatch(command.StartHoures, pattern))
|
||||
return op.Failed("لطفا ساعت شروع را به درستی وارد کنید");
|
||||
|
||||
if (!Regex.IsMatch(command.EndHours, pattern))
|
||||
return op.Failed("لطفا ساعت پایان را به درستی وارد کنید");
|
||||
|
||||
startH = TimeSpan.Parse(command.StartHoures);
|
||||
endH = TimeSpan.Parse(command.EndHours);
|
||||
if (startH == endH)
|
||||
return op.Failed("ساعت شروع و پایان نباید برابر باشد");
|
||||
}
|
||||
|
||||
if (command.LeaveType == "استعلاجی" && string.IsNullOrWhiteSpace(command.StartLeave))
|
||||
return op.Failed("لطفا تاریخ شروع را وارد کنید");
|
||||
@@ -227,14 +229,14 @@ public class LeaveApplication : ILeaveApplication
|
||||
var end = command.PaidLeaveType == "ساعتی" ? start : command.EndLeave.ToGeorgianDateTime();
|
||||
var checkErr = _leaveRepository.CheckErrors(start, end, command.EmployeeId, command.WorkshopId);
|
||||
|
||||
|
||||
|
||||
if (checkErr.HasChekout)
|
||||
return op.Failed(checkErr.CheckoutErrMessage);
|
||||
if (checkErr.HasLeftWork)
|
||||
return op.Failed(checkErr.LeftWorlErrMessage);
|
||||
if (start > end)
|
||||
return op.Failed("تارخ شروع از پایان بزرگتر است");
|
||||
|
||||
|
||||
|
||||
//var totalHoursbetween = new TimeSpan();
|
||||
//totalHoursbetween = (end - start);
|
||||
@@ -248,67 +250,71 @@ public class LeaveApplication : ILeaveApplication
|
||||
if (start > end)
|
||||
end = end.AddDays(1);
|
||||
|
||||
var totalLeavHourses = (end - start);
|
||||
var totalLeavHourses = (end - start);
|
||||
var h = totalLeavHourses.Hours < 10 ? $"0{totalLeavHourses.Hours}" : $"{totalLeavHourses.Hours}";
|
||||
var m = totalLeavHourses.Minutes < 10 ? $"0{totalLeavHourses.Minutes}" : $"{totalLeavHourses.Minutes}";
|
||||
totalhourses = $"{h}:{m}";
|
||||
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("برای ساعت شروع سابقه مرخصی وجود دارد");
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("برای ساعت شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("برای ساعت پایان سابقه مرخصی وجود دارد");
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("برای ساعت پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
|
||||
var end24 = endH.Hours == 0 && endH.Minutes == 0 ? end.AddDays(-1) : end;
|
||||
if (_leaveRepository.Exists(x =>
|
||||
(x.StartLeave.Date == start.Date || x.EndLeave.Date == end24.Date) && (x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id)))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
}
|
||||
(x.StartLeave.Date == start.Date || x.EndLeave.Date == end24.Date) && (x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id)))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
}
|
||||
else if (command.LeaveType == "استحقاقی" && command.PaidLeaveType == "روزانه")
|
||||
{
|
||||
var totalLeavHourses = (end - start).TotalDays + 1;
|
||||
totalhourses = $"{(int)totalLeavHourses}";
|
||||
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
}
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
}
|
||||
|
||||
if (command.LeaveType == "استعلاجی")
|
||||
{
|
||||
var totalLeavHourses = (end - start).TotalDays + 1;
|
||||
totalhourses = $"{(int)totalLeavHourses}";
|
||||
command.PaidLeaveType = "روزانه";
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
}
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه" && x.id != command.Id))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی" && x.id != command.Id))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
}
|
||||
|
||||
var year = Convert.ToInt32(command.StartLeave.Substring(0, 4));
|
||||
var year = Convert.ToInt32(command.StartLeave.Substring(0, 4));
|
||||
var month = Convert.ToInt32(command.StartLeave.Substring(5, 2));
|
||||
|
||||
var validation = ValidateNewLeaveWithExistingRollCalls(command.WorkshopId, command.EmployeeId, command.PaidLeaveType, start, end);
|
||||
if (validation.IsSuccedded == false)
|
||||
return validation;
|
||||
|
||||
var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
|
||||
var workshopName = _workshopRepository.GetDetails(command.WorkshopId).WorkshopName;
|
||||
leave.Edit(start, end, totalhourses, command.WorkshopId, command.EmployeeId
|
||||
@@ -350,13 +356,13 @@ public class LeaveApplication : ILeaveApplication
|
||||
return _leaveRepository.CheckIfValidToEdit(id);
|
||||
}
|
||||
|
||||
public OperationResult<bool> HasLeave(long workshopId, long employeeId, string dateFa)
|
||||
public OperationResult<bool> HasDailyLeave(long workshopId, long employeeId, string dateFa)
|
||||
{
|
||||
OperationResult<bool> op = new();
|
||||
DateTime date = dateFa.ToGeorgianDateTime();
|
||||
if (date == Tools.GetUndefinedDateTime())
|
||||
return op.Failed("تاریخ وارد شده صحیح نمی باشد");
|
||||
var result = _leaveRepository.HasLeave(employeeId, workshopId, date);
|
||||
var result = _leaveRepository.HasDailyLeave(employeeId, workshopId, date);
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
|
||||
@@ -386,15 +392,26 @@ public class LeaveApplication : ILeaveApplication
|
||||
{
|
||||
return _leaveRepository.LastLeaveMain(searchModel);
|
||||
}
|
||||
|
||||
#region Pooya
|
||||
public OperationResult ValidateNewLeaveWithExistingRollCalls(long workshopId, long employeeId, DateTime start, DateTime end)
|
||||
public OperationResult ValidateNewLeaveWithExistingRollCalls(long workshopId, long employeeId, string paidLeaveType, DateTime start, DateTime end)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var rollCallsInDate = _rollCallRepository.GetEmployeeRollCallsHistoryAll(workshopId, employeeId, start, end);
|
||||
if (rollCallsInDate.Any())
|
||||
return op.Failed("در این بازه زمانی رکورد حضور غیاب برای این شخص وجود دارد");
|
||||
return op.Succcedded();
|
||||
OperationResult op = new();
|
||||
var rollCallsInDate = _rollCallRepository.GetEmployeeRollCallsHistoryAllByDate(workshopId, employeeId, start, end);
|
||||
if (paidLeaveType == "ساعتی")
|
||||
{
|
||||
if (rollCallsInDate.Any(x => x.EndDate >= start && x.StartDate <= end))
|
||||
return op.Failed("در این بازه زمانی رکورد حضور غیاب برای این شخص وجود دارد");
|
||||
}
|
||||
else
|
||||
{
|
||||
var rollCallsInDateGrouped = rollCallsInDate.GroupBy(x => x.StartDate.Value.Date);
|
||||
if (rollCallsInDateGrouped.Any(x => x.Key.Date >= start && x.Key.Date <= end))
|
||||
return op.Failed("در این روز رکورد حضور غیاب برای این شخص وجود دارد");
|
||||
|
||||
}
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
public OperationResult ManualEdit(CreateOrEditEmployeeRollCall command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
|
||||
var activities = command.RollCallRecords.Select(x => (x.StartTime, x.EndTime));
|
||||
|
||||
DateTime date = command.DateFa.ToGeorgianDateTime();
|
||||
if (date == Tools.GetUndefinedDateTime())
|
||||
@@ -173,7 +173,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
if (command.RollCallRecords == null || command.RollCallRecords.Count == 0)
|
||||
return operation.Failed("خطای سیستمی");
|
||||
|
||||
if (_leaveRepository.HasLeave(command.EmployeeId, command.WorkshopId, date))
|
||||
if (_leaveRepository.HasDailyLeave(command.EmployeeId, command.WorkshopId, date))
|
||||
return operation.Failed("در روز مرخصی کارمند نمی توانید حضور غیاب ثبت کنید");
|
||||
|
||||
var employeeStatuses = _rollCallEmployeeRepository.GetByEmployeeIdWithStatuses(command.EmployeeId)
|
||||
@@ -259,8 +259,17 @@ public class RollCallApplication : IRollCallApplication
|
||||
return operation.Failed("شروع رکورد حضور غیاب نمی تواند در روز های بعد از تاریخ تعیین شده باشد");
|
||||
|
||||
#endregion
|
||||
foreach (var activity in result)
|
||||
{
|
||||
|
||||
if (result == null || !result.All(x => employeeStatuses.Any(y => x.Start >= y.StartDateGr || x.End <= y.EndDateGr)))
|
||||
//مرخصی روزانه در بالا چک شده است
|
||||
var leave = _leaveRepository.GetByWorkshopIdEmployeeIdInDates(command.WorkshopId, command.EmployeeId, activity.Start, activity.End)
|
||||
.Where(x => x.PaidLeaveType == "ساعتی");
|
||||
if (leave.Any())
|
||||
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
||||
}
|
||||
|
||||
if (result == null || !result.All(x => employeeStatuses.Any(y => x.Start >= y.StartDateGr && x.End <= y.EndDateGr)))
|
||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
public bool CheckIfValidToEdit(long id)
|
||||
{
|
||||
var leave = _context.LeaveList.FirstOrDefault(x => x.id == id);
|
||||
@@ -363,12 +363,28 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
|
||||
return op.Failed("موردی یافت نشد");
|
||||
}
|
||||
|
||||
public bool HasLeave(long employeeId, long workshopId, DateTime date)
|
||||
#region Pooya
|
||||
public bool HasDailyLeave(long employeeId, long workshopId, DateTime date)
|
||||
{
|
||||
return _context.LeaveList.Where(x => (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "روزانه") ||
|
||||
x.LeaveType == "استعلاجی")
|
||||
.FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartLeave.Date <= date.Date && x.EndLeave.Date >= date.Date) != null;
|
||||
}
|
||||
public List<LeaveViewModel> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime start, DateTime end)
|
||||
{
|
||||
return _context.LeaveList.Where(x => x.EmployeeId == employeeId && x.EndLeave >= start && x.StartLeave <= end)
|
||||
.Select(x => new LeaveViewModel
|
||||
{
|
||||
EmployeeId = employeeId,
|
||||
WorkshopId = workshopId,
|
||||
PaidLeaveType = x.PaidLeaveType,
|
||||
LeaveType = x.LeaveType,
|
||||
StartLeaveGr = x.StartLeave,
|
||||
EndLeaveGr = x.EndLeave
|
||||
}).ToList();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool CheckContractExist(DateTime myDate, long employeeId, long workshopId)
|
||||
{
|
||||
|
||||
@@ -377,8 +377,9 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
|
||||
//roll calls for current workshop where shift start is in dateIndex date (filters today's shifts)
|
||||
var rollCallsQuery = _context.RollCalls
|
||||
.Where(x => x.WorkshopId == workshopId && x.StartDate.HasValue &&
|
||||
x.StartDate.Value.Date >= startSearch.Date && x.StartDate.Value.Date <= endSearch.Date && x.RollCallModifyType != RollCallModifyType.Undefined &&
|
||||
x.RollCallModifyType != RollCallModifyType.CutByBgService);
|
||||
x.StartDate.Value.Date >= startSearch.Date && x.StartDate.Value.Date <= endSearch.Date &&
|
||||
x.RollCallModifyType != RollCallModifyType.Undefined);
|
||||
|
||||
|
||||
|
||||
//get active employees of workshop in dateIndex date
|
||||
@@ -409,7 +410,6 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId
|
||||
|
||||
}),
|
||||
IsHoliday = _holidayItemApplication.IsHoliday(day),
|
||||
IsFriday = day.DayOfWeek == DayOfWeek.Friday
|
||||
@@ -419,6 +419,19 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<RollCallViewModel> GetEmployeeRollCallsHistoryAllByDate(long workshopId, long employeeId, DateTime start, DateTime end)
|
||||
{
|
||||
return _context.RollCalls.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
||||
x.EndDate.Value.Date >= start.Date && x.StartDate.Value.Date <= end.Date)
|
||||
.Select(x => new RollCallViewModel
|
||||
{
|
||||
EmployeeId = employeeId,
|
||||
WorkshopId = workshopId,
|
||||
StartDate = x.StartDate,
|
||||
EndDate = x.EndDate
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
//سوابق حضور غیاب کارگاه
|
||||
public RollCallsByDateViewModel GetWorkshopRollCallHistory(RollCallSearchModel searchModel)
|
||||
{
|
||||
|
||||
@@ -198,6 +198,7 @@
|
||||
var antiForgeryToken = $('@Html.AntiForgeryToken()').val();
|
||||
var loadCameraAccountsAjax = `@Url.Page("CameraAccounts", "CameraAccounts")`;
|
||||
var changeCameraAccountStatusAjax = `@Url.Page("./CameraAccounts", "CameraAccountChangeStatus")`;
|
||||
var directLoginUrl = `@Url.Page("./CameraAccounts", "DirectCameraAccountLogin")`;
|
||||
var wpId = Number(@Model.WorkshopId);
|
||||
</script>
|
||||
<script src="~/AssetsAdminNew/RollCall/js/CameraAccounts.js?ver=@adminVersion"></script>
|
||||
|
||||
@@ -216,6 +216,21 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.RollCall
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public IActionResult OnGetDirectCameraAccountLogin(long id)
|
||||
{
|
||||
var res = _accountApplication.DirectCameraLogin(id);
|
||||
if (res.IsSuccedded)
|
||||
return Redirect("/Camera");
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = res.IsSuccedded,
|
||||
message = res.Message
|
||||
});
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.RollCall
|
||||
isSuccess = resultData.Any();
|
||||
}
|
||||
|
||||
var result = _leaveApplication.HasLeave(workshopId, employeeId, date);
|
||||
var result = _leaveApplication.HasDailyLeave(workshopId, employeeId, date);
|
||||
var isLeave = result.IsSuccedded ? result.Data : false;
|
||||
|
||||
var isNullEndDate = resultData.Any(x => x.EndDate == null);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.CustomizeCheckout
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
HasCustomizeCheckoutService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(_workshopId).HasCustomizeCheckoutService;
|
||||
HasCustomizeCheckoutService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(_workshopId)?.HasCustomizeCheckoutService;
|
||||
|
||||
var workshopInfo = _workshopApplication.GetWorkshopInfo(_workshopId);
|
||||
WorkshopFullName = workshopInfo.WorkshopFullName;
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees
|
||||
|
||||
HasEmployees = Employees.PersonnelInfoViewModels.Count > 0 ? true : false;
|
||||
|
||||
HasCustomizeCheckoutService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(id).HasCustomizeCheckoutService;
|
||||
HasCustomizeCheckoutService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(id)?.HasCustomizeCheckoutService;
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
isSuccess = resultData.Any();
|
||||
}
|
||||
|
||||
var result = _leaveApplication.HasLeave(workshopId, employeeId, date);
|
||||
var result = _leaveApplication.HasDailyLeave(workshopId, employeeId, date);
|
||||
var isLeave = result.IsSuccedded ? result.Data : false;
|
||||
|
||||
var isNullEndDate = resultData.Any(x => x.EndDate == null);
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace ServiceHost.Areas.Client.Pages
|
||||
|
||||
#endregion
|
||||
|
||||
HasCustomizeCheckoutService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopIDecrypt).HasCustomizeCheckoutService;
|
||||
HasCustomizeCheckoutService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopIDecrypt)?.HasCustomizeCheckoutService;
|
||||
|
||||
#region TodayDate
|
||||
|
||||
|
||||
@@ -88,6 +88,28 @@ function loadDataCameraAccountAjax() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="Rtable-cell d-md-flex justify-content-end width6">
|
||||
<div class="Rtable-cell--content align-items-center d-flex d-md-flex justify-content-end">
|
||||
<a class="btn-pass ChangePassword d-none d-md-block" href="${directLoginUrl}&id=${item.id}" id="directLogin_${item.id}" type="button">
|
||||
<span class="spanTxt d-none"> ورود مستقیم </span>
|
||||
<span class="spanSvg">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" />
|
||||
</svg>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<button type="button" class="btn-more position-relative d-md-none d-flex" style="width: 36px;padding: 0;height: 36px;align-items: center;justify-content: center;position: relative !important;">
|
||||
<span class="mx-1 align-items-center d-flex justify-content-center"></span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16" fill="currentColor">
|
||||
<circle cx="8.4001" cy="8.39922" r="1.2" transform="rotate(90 8.4001 8.39922)"/>
|
||||
<circle cx="8.4001" cy="4.39922" r="1.2" transform="rotate(90 8.4001 4.39922)"/>
|
||||
<circle cx="8.4001" cy="12.3992" r="1.2" transform="rotate(90 8.4001 12.3992)"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ function fetchAndDisplayRollCallData(employeeId, dateFa) {
|
||||
|
||||
if (response.hasLeave) {
|
||||
htmlElement = `
|
||||
<div class="text-center">این پرسنل مرخصی ثبت شده است.</div>
|
||||
<div class="text-center"> برای این پرسنل مرخصی ثبت شده است </div>
|
||||
`;
|
||||
$('#appendChildTimeWorkHtml').html(htmlElement);
|
||||
$('.btn-register').addClass('disable');
|
||||
|
||||
Reference in New Issue
Block a user