153 lines
6.1 KiB
C#
153 lines
6.1 KiB
C#
using _0_Framework.Application;
|
|
using Company.Domain.WorkshopAccountAgg;
|
|
using CompanyManagment.App.Contracts.Employee;
|
|
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
|
using CompanyManagment.App.Contracts.Error;
|
|
using CompanyManagment.App.Contracts.Workshop;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using WorkFlow.Application.Contracts.AdminWorkFlow;
|
|
|
|
namespace ServiceHost.Areas.AdminNew.Pages.Company.WorkFlow
|
|
{
|
|
[Authorize]
|
|
public class EmployeesDocumentsModel : PageModel
|
|
{
|
|
private readonly IWorkshopApplication _workshopApplication;
|
|
private readonly IEmployeeDocumentsApplication _employeeDocumentsApplication;
|
|
private readonly IAdminWorkFlowApplication _adminWorkFlowApplication;
|
|
private readonly IWorkshopAccountRepository _workshopAccountRepository;
|
|
private readonly IAuthHelper _authHelper;
|
|
public int EmployeeDocumentsAwaitingSubmitCount;
|
|
|
|
public EmployeesDocumentsModel(IAdminWorkFlowApplication adminWorkFlowApplication, IWorkshopApplication workshopApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IWorkshopAccountRepository workshopAccountRepository, IAuthHelper authHelper)
|
|
{
|
|
_adminWorkFlowApplication = adminWorkFlowApplication;
|
|
_workshopApplication = workshopApplication;
|
|
_employeeDocumentsApplication = employeeDocumentsApplication;
|
|
_workshopAccountRepository = workshopAccountRepository;
|
|
_authHelper = authHelper;
|
|
}
|
|
|
|
public async System.Threading.Tasks.Task OnGet()
|
|
{
|
|
var accountId = _authHelper.CurrentAccountId();
|
|
var accountWorkshops = _workshopAccountRepository.GetList(accountId).Select(x => x.WorkshopId).ToList();
|
|
EmployeeDocumentsAwaitingSubmitCount = await _adminWorkFlowApplication.GetEmployeeDocumentWorkFlowCountsForAdmin(accountWorkshops);
|
|
}
|
|
|
|
public IActionResult OnGetWorkshopsWithDocumentsAwaitingUploadAjax()
|
|
{
|
|
var accountId = _authHelper.CurrentAccountId();
|
|
var accountWorkshops= _workshopAccountRepository.GetList(accountId).Select(x=>x.WorkshopId).ToList();
|
|
var resultData = _adminWorkFlowApplication.GetWorkshopsWithDocumentsAwaitingUploadForAdmin(accountWorkshops);
|
|
|
|
return new JsonResult(new
|
|
{
|
|
success = true,
|
|
data = resultData
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetByWorkshopIdWithItemsForAdminWorkFlow(long workshopId)
|
|
{
|
|
var resultData = _employeeDocumentsApplication.GetByWorkshopIdWithItemsForAdminWorkFlow(workshopId);
|
|
|
|
return new JsonResult(new
|
|
{
|
|
success = true,
|
|
data = resultData
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetCreateUploadDocument(long workshopId, long employeeId)
|
|
{
|
|
var employeeDocument = _employeeDocumentsApplication.GetDetailsForAdmin(employeeId, workshopId);
|
|
return Partial("_ModalEmployeeDocuments/ModalUploadDocument", employeeDocument);
|
|
}
|
|
|
|
public IActionResult OnPostCreateUploadDocument(AddEmployeeDocumentItem command)
|
|
{
|
|
var result = _employeeDocumentsApplication.AddEmployeeDocumentItemForClient(command);
|
|
var employeeDocument = _employeeDocumentsApplication.GetDetailsForAdmin(command.EmployeeId, command.WorkshopId);
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = result.IsSuccedded,
|
|
message = result.Message,
|
|
imageSrc = employeeDocument
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostRemoveEmployeeDocumentByLabel(long workshopId, long employeeId, DocumentItemLabel label)
|
|
{
|
|
var result = _employeeDocumentsApplication.RemoveClientDocumentItemsByAdminTemp(workshopId, employeeId, label);
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = result.IsSuccedded,
|
|
message = result.Message
|
|
});
|
|
}
|
|
public IActionResult OnPostRemoveClientEmployeeDocumentItemsByLabels(long workshopId, long employeeId, List<DocumentItemLabel> labels)
|
|
{
|
|
var result = _employeeDocumentsApplication.RemoveClientDocumentItemsByAdmin(workshopId, employeeId, labels);
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = result.IsSuccedded,
|
|
message = result.Message
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostSaveSubmit(SubmitEmployeeDocuments cmd)
|
|
{
|
|
|
|
var result = _employeeDocumentsApplication.SubmitDocumentItemsByAdminInWorkFlow(cmd);
|
|
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = result.IsSuccedded,
|
|
message = result.Message,
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetShowPicture(string filePath)
|
|
{
|
|
if (string.IsNullOrEmpty(filePath))
|
|
return NotFound();
|
|
|
|
|
|
if (!System.IO.File.Exists(filePath))
|
|
return NotFound();
|
|
|
|
var contentType = Tools.GetContentTypeImage(Path.GetExtension(filePath));
|
|
return PhysicalFile(filePath, contentType);
|
|
}
|
|
|
|
public IActionResult OnPostCancelOperation(long workshopId, long employeeId)
|
|
{
|
|
var result = _employeeDocumentsApplication.DeleteUnsubmittedItems(workshopId, employeeId);
|
|
return new JsonResult(new
|
|
{
|
|
success = result.IsSuccedded,
|
|
message = result.Message
|
|
});
|
|
}
|
|
|
|
public async Task<IActionResult> OnGetEditEmployeeModal(long employeeId, long workshopId)
|
|
{
|
|
var command = await _adminWorkFlowApplication.GetEmployeeEditInEmployeeDocumentWorkFlow(employeeId, workshopId);
|
|
return Partial("_ModalEmployeeDocuments/ModalEmployeeEdit", command);
|
|
}
|
|
|
|
public async Task<IActionResult> OnPostEditEmployeeModal(EditEmployeeInEmployeeDocument command)
|
|
{
|
|
var result = await _adminWorkFlowApplication.EditEmployeeInEmployeeDocumentWorkFlow(command);
|
|
return new JsonResult(new
|
|
{
|
|
success = result.IsSuccedded,
|
|
message = result.Message
|
|
});
|
|
}
|
|
}
|
|
}
|