area cleanUp
This commit is contained in:
@@ -1,415 +1,384 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Claims;
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using CompanyManagment.App.Contracts.ClientDashboard;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.HolidayItem;
|
||||
using CompanyManagment.App.Contracts.Leave;
|
||||
using CompanyManagment.App.Contracts.PaymentToEmployee;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.Application;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using PersianTools.Core;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||
using CompanyManagment.App.Contracts.RollCallService;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Pages
|
||||
namespace ServiceHost.Areas.Client.Pages;
|
||||
|
||||
[Authorize]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
[Authorize]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
private readonly ILeaveApplication _leaveApplication;
|
||||
private readonly IEmployeeApplication _employeeApplication;
|
||||
private readonly IPaymentToEmployeeApplication _paymentToEmployeeApplication;
|
||||
private readonly IPaymentToEmployeeItemApplication _paymentToEmployeeItemApplication;
|
||||
private readonly IHolidayItemApplication _holidayItemApplication;
|
||||
private readonly IPasswordHasher _passwordHasher;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
public string profilePicture { get; set; }
|
||||
public string AccountFullName { get; set; }
|
||||
public List<CalenderViewModel> CalenderViewModels;
|
||||
public string Today { get; set; }
|
||||
public string TodayDate { get; set; }
|
||||
public List<WorkshopViewModel> Workshops;
|
||||
public string SelectedWorkshop;
|
||||
public ConnectedPersonnelViewModel Employees;
|
||||
public List<LeaveMainViewModel> LeaveSearch;
|
||||
public string workshopId { get; set; }
|
||||
public int PageIndex;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IEmployeeApplication _employeeApplication;
|
||||
private readonly IHolidayItemApplication _holidayItemApplication;
|
||||
private readonly ILeaveApplication _leaveApplication;
|
||||
private readonly IPasswordHasher _passwordHasher;
|
||||
private readonly IPaymentToEmployeeApplication _paymentToEmployeeApplication;
|
||||
private readonly IPaymentToEmployeeItemApplication _paymentToEmployeeItemApplication;
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
public List<CalenderViewModel> CalenderViewModels;
|
||||
public ConnectedPersonnelViewModel Employees;
|
||||
public List<LeaveMainViewModel> LeaveSearch;
|
||||
public int PageIndex;
|
||||
public string SelectedWorkshop;
|
||||
public List<WorkshopViewModel> Workshops;
|
||||
|
||||
public IndexModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, ILeaveApplication leaveApplication, IEmployeeApplication employeeApplication, IPaymentToEmployeeItemApplication paymentToEmployeeItemApplication, IPaymentToEmployeeApplication paymentToEmployeeApplication, IHolidayItemApplication holidayItemApplication)
|
||||
{
|
||||
_workshopApplication = workshopApplication;
|
||||
_employeeApplication = employeeApplication;
|
||||
_paymentToEmployeeItemApplication = paymentToEmployeeItemApplication;
|
||||
_paymentToEmployeeApplication = paymentToEmployeeApplication;
|
||||
_holidayItemApplication = holidayItemApplication;
|
||||
_leaveApplication = leaveApplication;
|
||||
_authHelper = authHelper;
|
||||
_passwordHasher = passwordHasher;
|
||||
}
|
||||
public IndexModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication,
|
||||
ILeaveApplication leaveApplication, IEmployeeApplication employeeApplication,
|
||||
IPaymentToEmployeeItemApplication paymentToEmployeeItemApplication,
|
||||
IPaymentToEmployeeApplication paymentToEmployeeApplication, IHolidayItemApplication holidayItemApplication)
|
||||
{
|
||||
_workshopApplication = workshopApplication;
|
||||
_employeeApplication = employeeApplication;
|
||||
_paymentToEmployeeItemApplication = paymentToEmployeeItemApplication;
|
||||
_paymentToEmployeeApplication = paymentToEmployeeApplication;
|
||||
_holidayItemApplication = holidayItemApplication;
|
||||
_leaveApplication = leaveApplication;
|
||||
_authHelper = authHelper;
|
||||
_passwordHasher = passwordHasher;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
profilePicture = _authHelper.CurrentAccountInfo().ProfilePhoto;
|
||||
AccountFullName = _authHelper.CurrentAccountInfo().Fullname;
|
||||
var todayGr = DateTime.Now;
|
||||
public string profilePicture { get; set; }
|
||||
public string AccountFullName { get; set; }
|
||||
public string Today { get; set; }
|
||||
public string TodayDate { get; set; }
|
||||
public string workshopId { get; set; }
|
||||
|
||||
#region TodayDate
|
||||
public void OnGet()
|
||||
{
|
||||
profilePicture = _authHelper.CurrentAccountInfo().ProfilePhoto;
|
||||
AccountFullName = _authHelper.CurrentAccountInfo().Fullname;
|
||||
var todayGr = DateTime.Now;
|
||||
|
||||
var todayFa = todayGr.ToFarsi();
|
||||
var syear = Convert.ToInt32(todayFa.Substring(0, 4));
|
||||
var smonth = Convert.ToInt32(todayFa.Substring(5, 2));
|
||||
var sday = Convert.ToInt32(todayFa.Substring(8, 2));
|
||||
var todayPersian = new PersianDateTime(syear, smonth, sday);
|
||||
var threeDaysBeforeGr = new PersianDateTime(syear, smonth, sday);
|
||||
var threeDaysAfterGr = new PersianDateTime(syear, smonth, sday);
|
||||
#region TodayDate
|
||||
|
||||
var dayOfWeek = todayPersian.DayOfWeek;
|
||||
var month = todayPersian.MonthOfYear;
|
||||
var day = todayFa.Substring(8, 2);
|
||||
var year = todayFa.Substring(0, 4);
|
||||
TodayDate = $"{dayOfWeek} - {day} {month} {year}";
|
||||
#endregion
|
||||
var todayFa = todayGr.ToFarsi();
|
||||
var syear = Convert.ToInt32(todayFa.Substring(0, 4));
|
||||
var smonth = Convert.ToInt32(todayFa.Substring(5, 2));
|
||||
var sday = Convert.ToInt32(todayFa.Substring(8, 2));
|
||||
var todayPersian = new PersianDateTime(syear, smonth, sday);
|
||||
var threeDaysBeforeGr = new PersianDateTime(syear, smonth, sday);
|
||||
var threeDaysAfterGr = new PersianDateTime(syear, smonth, sday);
|
||||
|
||||
#region Calender
|
||||
var dayOfWeek = todayPersian.DayOfWeek;
|
||||
var month = todayPersian.MonthOfYear;
|
||||
var day = todayFa.Substring(8, 2);
|
||||
var year = todayFa.Substring(0, 4);
|
||||
TodayDate = $"{dayOfWeek} - {day} {month} {year}";
|
||||
|
||||
var todayFor = todayPersian;
|
||||
#endregion
|
||||
|
||||
threeDaysBeforeGr = threeDaysBeforeGr.AddDays(-3);
|
||||
#region Calender
|
||||
|
||||
threeDaysAfterGr = threeDaysAfterGr.AddDays(3);
|
||||
var todayFor = todayPersian;
|
||||
|
||||
threeDaysBeforeGr = threeDaysBeforeGr.AddDays(-3);
|
||||
|
||||
threeDaysAfterGr = threeDaysAfterGr.AddDays(3);
|
||||
|
||||
|
||||
var d1 = threeDaysBeforeGr;
|
||||
var d2 = threeDaysAfterGr;
|
||||
var d1 = threeDaysBeforeGr;
|
||||
var d2 = threeDaysAfterGr;
|
||||
|
||||
var calenderList = new List<CalenderViewModel>();
|
||||
for (var da = d1; da <= d2; da = da.AddDays(1))
|
||||
{
|
||||
var currentDay = $"{da}".Substring(8, 2);
|
||||
var dayOfWeekCurrent = "";
|
||||
var calenderList = new List<CalenderViewModel>();
|
||||
for (var da = d1; da <= d2; da = da.AddDays(1))
|
||||
{
|
||||
var currentDay = $"{da}".Substring(8, 2);
|
||||
var dayOfWeekCurrent = "";
|
||||
|
||||
switch ($"{da.DayOfWeek}")
|
||||
{
|
||||
case "شنبه":
|
||||
dayOfWeekCurrent = "شنبه";
|
||||
break;
|
||||
case "یکشنبه":
|
||||
dayOfWeekCurrent = "1 شنبه";
|
||||
break;
|
||||
case "دوشنبه":
|
||||
dayOfWeekCurrent = "2 شنبه";
|
||||
break;
|
||||
case "سه شنبه":
|
||||
dayOfWeekCurrent = "3 شنبه";
|
||||
break;
|
||||
case "چهارشنبه":
|
||||
dayOfWeekCurrent = "4 شنبه";
|
||||
break;
|
||||
case "پنج شنبه":
|
||||
dayOfWeekCurrent = "5 شنبه";
|
||||
break;
|
||||
case "جمعه":
|
||||
dayOfWeekCurrent = "آدینه";
|
||||
break;
|
||||
}
|
||||
switch ($"{da.DayOfWeek}")
|
||||
{
|
||||
case "شنبه":
|
||||
dayOfWeekCurrent = "شنبه";
|
||||
break;
|
||||
case "یکشنبه":
|
||||
dayOfWeekCurrent = "1 شنبه";
|
||||
break;
|
||||
case "دوشنبه":
|
||||
dayOfWeekCurrent = "2 شنبه";
|
||||
break;
|
||||
case "سه شنبه":
|
||||
dayOfWeekCurrent = "3 شنبه";
|
||||
break;
|
||||
case "چهارشنبه":
|
||||
dayOfWeekCurrent = "4 شنبه";
|
||||
break;
|
||||
case "پنج شنبه":
|
||||
dayOfWeekCurrent = "5 شنبه";
|
||||
break;
|
||||
case "جمعه":
|
||||
dayOfWeekCurrent = "آدینه";
|
||||
break;
|
||||
}
|
||||
|
||||
var BoolDateHoliday = da.ToGregorianDateTime();
|
||||
if (da == todayFor)
|
||||
{
|
||||
var calenderNewList = new CalenderViewModel()
|
||||
{
|
||||
DayNumber = currentDay,
|
||||
IsToday = true,
|
||||
DayOfWeek = dayOfWeekCurrent,
|
||||
Holiday = _holidayItemApplication.GetHoliday(BoolDateHoliday),
|
||||
};
|
||||
calenderList.Add(calenderNewList);
|
||||
}
|
||||
else
|
||||
{
|
||||
var calenderNewList = new CalenderViewModel()
|
||||
{
|
||||
DayNumber = currentDay,
|
||||
IsToday = false,
|
||||
DayOfWeek = dayOfWeekCurrent,
|
||||
Holiday = _holidayItemApplication.GetHoliday(BoolDateHoliday)
|
||||
};
|
||||
calenderList.Add(calenderNewList);
|
||||
var BoolDateHoliday = da.ToGregorianDateTime();
|
||||
if (da == todayFor)
|
||||
{
|
||||
var calenderNewList = new CalenderViewModel
|
||||
{
|
||||
DayNumber = currentDay,
|
||||
IsToday = true,
|
||||
DayOfWeek = dayOfWeekCurrent,
|
||||
Holiday = _holidayItemApplication.GetHoliday(BoolDateHoliday)
|
||||
};
|
||||
calenderList.Add(calenderNewList);
|
||||
}
|
||||
else
|
||||
{
|
||||
var calenderNewList = new CalenderViewModel
|
||||
{
|
||||
DayNumber = currentDay,
|
||||
IsToday = false,
|
||||
DayOfWeek = dayOfWeekCurrent,
|
||||
Holiday = _holidayItemApplication.GetHoliday(BoolDateHoliday)
|
||||
};
|
||||
calenderList.Add(calenderNewList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
CalenderViewModels = calenderList;
|
||||
|
||||
CalenderViewModels = calenderList;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Get Employee & Workshop List by JSON
|
||||
public IActionResult OnGetWorkshopList(WorkshopSearchModel searchModel)
|
||||
{
|
||||
Workshops = _workshopApplication.SearchForClient(searchModel).ToList();
|
||||
var selectedWorkshop = _workshopApplication.SearchForClient(searchModel).OrderByDescending(x => x.PersonnelCount).FirstOrDefault();
|
||||
SelectedWorkshop = selectedWorkshop.WorkshopFullName;
|
||||
|
||||
if (selectedWorkshop != null)
|
||||
{
|
||||
_authHelper.UpdateWorkshopSlugClaim(selectedWorkshop.Slug);
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
Workshops,
|
||||
workshopName = SelectedWorkshop
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnPostSelectWorkshop(string slug, WorkshopSearchModel searchModel)
|
||||
{
|
||||
var workshopId = _passwordHasher.SlugDecrypt(slug);
|
||||
if (workshopId != 0)
|
||||
{
|
||||
var workshop = _workshopApplication.SearchForClient(searchModel).FirstOrDefault(x => x.Id == workshopId);
|
||||
if (workshop != null)
|
||||
{
|
||||
_authHelper.UpdateWorkshopSlugClaim(workshop.Slug);
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccedded = true,
|
||||
message = "کارگاه مورد نظر شما انتخاب شد"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccedded = false,
|
||||
message = "کارگاه مورد نظر شما یافت نشد"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult OnGetEmployeeList()
|
||||
{
|
||||
var workshopSlug = User.FindFirst("WorkshopSlug").Value;
|
||||
var workshopId = _passwordHasher.SlugDecrypt(workshopSlug);
|
||||
if (workshopId > 0)
|
||||
{
|
||||
var filteredBlackResult = _workshopApplication.GetConnectedPersonnels(workshopId)
|
||||
.Where(x => !x.Black && x.ContractPerson)
|
||||
.GroupBy(x => x.EmployeeId)
|
||||
.Select(x => x.First())
|
||||
.OrderBy(x => x.PersonelCode)
|
||||
.ToList();
|
||||
|
||||
Employees = new ConnectedPersonnelViewModel()
|
||||
{
|
||||
ConnectedPersonnelViewModels = filteredBlackResult,
|
||||
};
|
||||
|
||||
return new JsonResult(new { Employees });
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new { Employees = new ConnectedPersonnelViewModel() });
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
public IActionResult OnGetLeaveCreate()
|
||||
{
|
||||
var command = new CreateLeave();
|
||||
public IActionResult OnGetLeaveCreate()
|
||||
{
|
||||
var command = new CreateLeave();
|
||||
|
||||
return Partial("LeaveCreate", command);
|
||||
}
|
||||
return Partial("LeaveCreate", command);
|
||||
}
|
||||
|
||||
public IActionResult OnPostLeaveSave(CreateLeave command)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
var workshopSlugCliam = User.FindFirstValue("WorkshopSlug");
|
||||
long workshopId = _passwordHasher.SlugDecrypt(workshopSlugCliam);
|
||||
if (workshopId > 0)
|
||||
{
|
||||
command.WorkshopId = workshopId;
|
||||
public IActionResult OnPostLeaveSave(CreateLeave command)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
var workshopSlugCliam = User.FindFirstValue("WorkshopSlug");
|
||||
var workshopId = _passwordHasher.SlugDecrypt(workshopSlugCliam);
|
||||
if (workshopId > 0)
|
||||
{
|
||||
command.WorkshopId = workshopId;
|
||||
|
||||
var result = _leaveApplication.Create(command);
|
||||
var result = _leaveApplication.Create(command);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
IsSuccedded = result.IsSuccedded,
|
||||
message = result.Message,
|
||||
PrintID = result.SendId
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
IsSuccedded = false,
|
||||
message = "کارگاه ای یافت نشده است",
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
IsSuccedded = false,
|
||||
message = "داده ای یافت نشد!",
|
||||
});
|
||||
}
|
||||
}
|
||||
return new JsonResult(new
|
||||
{
|
||||
result.IsSuccedded,
|
||||
message = result.Message,
|
||||
PrintID = result.SendId
|
||||
});
|
||||
}
|
||||
|
||||
#region Compute Leave Hourly and Daily
|
||||
public IActionResult OnGetComputeLeaveHourly(string startHours, string endHours)
|
||||
{
|
||||
var start = Convert.ToDateTime(startHours);
|
||||
var end = Convert.ToDateTime(endHours);
|
||||
if (start > end || start == end)
|
||||
{
|
||||
end = end.AddDays(1);
|
||||
}
|
||||
return new JsonResult(new
|
||||
{
|
||||
IsSuccedded = false,
|
||||
message = "کارگاه ای یافت نشده است"
|
||||
});
|
||||
}
|
||||
|
||||
var HourlyDate = (end - start);
|
||||
var hours = (int)HourlyDate.TotalHours;
|
||||
var minutes = HourlyDate.TotalMinutes % 60;
|
||||
return new JsonResult(new
|
||||
{
|
||||
IsSuccedded = false,
|
||||
message = "داده ای یافت نشد!"
|
||||
});
|
||||
}
|
||||
|
||||
if (hours > 0 && minutes > 0)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = hours + " " + "ساعت و" + " " + minutes + " " + "دقیقه",
|
||||
});
|
||||
}
|
||||
else if (hours > 0 && minutes == 0)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = hours + " " + "ساعت ",
|
||||
});
|
||||
}
|
||||
else if (hours == 0 && minutes > 0)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = minutes + " " + "دقیقه",
|
||||
});
|
||||
}
|
||||
public IActionResult OnGetLeaveList()
|
||||
{
|
||||
return Partial("LeaveList");
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
totalHours = $"{hours}",
|
||||
});
|
||||
}
|
||||
public IActionResult OnGetLeaveListData(long workshopId, long employeeId)
|
||||
{
|
||||
var workshop = _workshopApplication.GetDetails(workshopId);
|
||||
var employee = _employeeApplication.GetDetails(employeeId);
|
||||
var search = new LeaveSearchModel
|
||||
{
|
||||
WorkshopId = workshop.Id,
|
||||
EmployeeId = employee.Id
|
||||
};
|
||||
LeaveSearch = _leaveApplication.searchClient(search);
|
||||
return new JsonResult(new { LeaveSearch });
|
||||
}
|
||||
|
||||
public IActionResult OnGetComputeLeaveDaily(string startDay, string endDay)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(startDay) && !string.IsNullOrWhiteSpace(endDay))
|
||||
{
|
||||
var start = startDay.ToGeorgianDateTime();
|
||||
var end = endDay.ToGeorgianDateTime();
|
||||
if (end >= start)
|
||||
{
|
||||
var daysSpan = (end - start).TotalDays + 1;
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = $"{(int)daysSpan} روز",
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
status = false,
|
||||
res = "تاریخ پایان از تاریخ شروع کوچکتر است.",
|
||||
});
|
||||
}
|
||||
}
|
||||
public IActionResult OnGetPaymentToPersonnelCreate()
|
||||
{
|
||||
return Partial("PaymentToPersonnelCreate");
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = "",
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
public IActionResult OnPostPaymentToPersonnelSave(CreatePaymentToEmployee command)
|
||||
{
|
||||
var payDateFa = command.CreatePaymentToEmployeeItem.PayDateFa;
|
||||
command.Year = payDateFa.Substring(0, 4);
|
||||
command.Month = payDateFa.Substring(5, 2);
|
||||
|
||||
public IActionResult OnGetLeaveList()
|
||||
{
|
||||
return Partial("LeaveList");
|
||||
}
|
||||
var result = _paymentToEmployeeApplication.Create(command);
|
||||
|
||||
public IActionResult OnGetLeaveListData(long workshopId, long employeeId)
|
||||
{
|
||||
var workshop = _workshopApplication.GetDetails(workshopId);
|
||||
var employee = _employeeApplication.GetDetails(employeeId);
|
||||
var search = new LeaveSearchModel()
|
||||
{
|
||||
WorkshopId = workshop.Id,
|
||||
EmployeeId = employee.Id,
|
||||
};
|
||||
LeaveSearch = _leaveApplication.searchClient(search);
|
||||
return new JsonResult(new { LeaveSearch });
|
||||
}
|
||||
return new JsonResult(new
|
||||
{
|
||||
result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetPaymentToPersonnelCreate()
|
||||
{
|
||||
return Partial("PaymentToPersonnelCreate");
|
||||
}
|
||||
public IActionResult OnGetLastLeave(int pageIndex)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
var workshopSlugCliam = User.FindFirstValue("WorkshopSlug");
|
||||
var workshopId = _passwordHasher.SlugDecrypt(workshopSlugCliam);
|
||||
if (workshopId > 0)
|
||||
{
|
||||
var result = _leaveApplication.LastLeaveMain(workshopId, pageIndex);
|
||||
var pageIndexCount = result.Count();
|
||||
return new JsonResult(new
|
||||
{
|
||||
data = result,
|
||||
pageIndex = pageIndexCount
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnPostPaymentToPersonnelSave(CreatePaymentToEmployee command)
|
||||
{
|
||||
var payDateFa = command.CreatePaymentToEmployeeItem.PayDateFa;
|
||||
command.Year = payDateFa.Substring(0, 4);
|
||||
command.Month = payDateFa.Substring(5, 2);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var result = _paymentToEmployeeApplication.Create(command);
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
IsSuccedded = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
#region Get Employee & Workshop List by JSON
|
||||
|
||||
public IActionResult OnGetLastLeave(int pageIndex)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
var workshopSlugCliam = User.FindFirstValue("WorkshopSlug");
|
||||
long workshopId = _passwordHasher.SlugDecrypt(workshopSlugCliam);
|
||||
if (workshopId > 0)
|
||||
{
|
||||
var result = _leaveApplication.LastLeaveMain(workshopId, pageIndex);
|
||||
int pageIndexCount = result.Count();
|
||||
return new JsonResult(new
|
||||
{
|
||||
data = result,
|
||||
pageIndex = pageIndexCount
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public IActionResult OnGetWorkshopList(WorkshopSearchModel searchModel)
|
||||
{
|
||||
Workshops = _workshopApplication.SearchForClient(searchModel).ToList();
|
||||
var selectedWorkshop = _workshopApplication.SearchForClient(searchModel)
|
||||
.OrderByDescending(x => x.PersonnelCount).FirstOrDefault();
|
||||
SelectedWorkshop = selectedWorkshop.WorkshopFullName;
|
||||
|
||||
if (selectedWorkshop != null) _authHelper.UpdateWorkshopSlugClaim(selectedWorkshop.Slug);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
Workshops,
|
||||
workshopName = SelectedWorkshop
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnPostSelectWorkshop(string slug, WorkshopSearchModel searchModel)
|
||||
{
|
||||
var workshopId = _passwordHasher.SlugDecrypt(slug);
|
||||
if (workshopId != 0)
|
||||
{
|
||||
var workshop = _workshopApplication.SearchForClient(searchModel).FirstOrDefault(x => x.Id == workshopId);
|
||||
if (workshop != null) _authHelper.UpdateWorkshopSlugClaim(workshop.Slug);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccedded = true,
|
||||
message = "کارگاه مورد نظر شما انتخاب شد"
|
||||
});
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccedded = false,
|
||||
message = "کارگاه مورد نظر شما یافت نشد"
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetEmployeeList()
|
||||
{
|
||||
var workshopSlug = User.FindFirst("WorkshopSlug").Value;
|
||||
var workshopId = _passwordHasher.SlugDecrypt(workshopSlug);
|
||||
if (workshopId > 0)
|
||||
{
|
||||
var filteredBlackResult = _workshopApplication.GetConnectedPersonnels(workshopId)
|
||||
.Where(x => !x.Black && x.ContractPerson)
|
||||
.GroupBy(x => x.EmployeeId)
|
||||
.Select(x => x.First())
|
||||
.OrderBy(x => x.PersonelCode)
|
||||
.ToList();
|
||||
|
||||
Employees = new ConnectedPersonnelViewModel
|
||||
{
|
||||
ConnectedPersonnelViewModels = filteredBlackResult
|
||||
};
|
||||
|
||||
return new JsonResult(new { Employees });
|
||||
}
|
||||
|
||||
return new JsonResult(new { Employees = new ConnectedPersonnelViewModel() });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Compute Leave Hourly and Daily
|
||||
|
||||
public IActionResult OnGetComputeLeaveHourly(string startHours, string endHours)
|
||||
{
|
||||
var start = Convert.ToDateTime(startHours);
|
||||
var end = Convert.ToDateTime(endHours);
|
||||
if (start > end || start == end) end = end.AddDays(1);
|
||||
|
||||
var HourlyDate = end - start;
|
||||
var hours = (int)HourlyDate.TotalHours;
|
||||
var minutes = HourlyDate.TotalMinutes % 60;
|
||||
|
||||
if (hours > 0 && minutes > 0)
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = hours + " " + "ساعت و" + " " + minutes + " " + "دقیقه"
|
||||
});
|
||||
if (hours > 0 && minutes == 0)
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = hours + " " + "ساعت "
|
||||
});
|
||||
if (hours == 0 && minutes > 0)
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = minutes + " " + "دقیقه"
|
||||
});
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
totalHours = $"{hours}"
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetComputeLeaveDaily(string startDay, string endDay)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(startDay) && !string.IsNullOrWhiteSpace(endDay))
|
||||
{
|
||||
var start = startDay.ToGeorgianDateTime();
|
||||
var end = endDay.ToGeorgianDateTime();
|
||||
if (end >= start)
|
||||
{
|
||||
var daysSpan = (end - start).TotalDays + 1;
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = $"{(int)daysSpan} روز"
|
||||
});
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
status = false,
|
||||
res = "تاریخ پایان از تاریخ شروع کوچکتر است."
|
||||
});
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
res = ""
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user