128 lines
4.0 KiB
C#
128 lines
4.0 KiB
C#
using System.Collections.Generic;
|
|
using System.Security.Claims;
|
|
using _0_Framework.Application;
|
|
using Company.Domain.EmployeeAgg;
|
|
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using WorkFlow.Infrastructure.ACL.EmployeeDocuments;
|
|
|
|
namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow.EmployeeDocuments
|
|
{
|
|
|
|
public class IndexModel : PageModel
|
|
{
|
|
private readonly IPasswordHasher _passwordHasher;
|
|
private readonly IAuthHelper _authHelper;
|
|
private readonly IHttpContextAccessor _contextAccessor;
|
|
private readonly IEmployeeDocumentsApplication _employeeDocumentsApplication;
|
|
private readonly long _workshopId;
|
|
|
|
public IndexModel(IHttpContextAccessor contextAccessor, IPasswordHasher passwordHasher, IEmployeeDocumentsApplication employeeDocumentsApplication, IAuthHelper authHelper)
|
|
{
|
|
_contextAccessor = contextAccessor;
|
|
_passwordHasher = passwordHasher;
|
|
_employeeDocumentsApplication = employeeDocumentsApplication;
|
|
_authHelper = authHelper;
|
|
|
|
var workshopHash = _contextAccessor.HttpContext?.User.FindFirstValue("WorkshopSlug");
|
|
_workshopId = _passwordHasher.SlugDecrypt(workshopHash);
|
|
|
|
if (_workshopId < 1)
|
|
throw new InvalidDataException("اختلال در کارگاه");
|
|
}
|
|
|
|
public void OnGet()
|
|
{
|
|
}
|
|
|
|
public async Task<IActionResult> OnGetClientRejectedDocumentForClient()
|
|
{
|
|
var currentAccountId = _authHelper.CurrentAccountId();
|
|
var resultData = await _employeeDocumentsApplication.GetClientRejectedDocumentForClient(_workshopId, currentAccountId);
|
|
return new JsonResult(new
|
|
{
|
|
success = true,
|
|
data = resultData,
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetCreateUploadDocument(long employeeId)
|
|
{
|
|
var employeeDocument = _employeeDocumentsApplication.GetDetailsForClient(employeeId, _workshopId);
|
|
|
|
return Partial("./ModalUploadDocument", employeeDocument);
|
|
}
|
|
|
|
public IActionResult OnPostCreateUploadDocument(AddEmployeeDocumentItem command)
|
|
{
|
|
command.WorkshopId = _workshopId;
|
|
|
|
var result = _employeeDocumentsApplication.AddEmployeeDocumentItemForClient(command);
|
|
var employeeDocument = _employeeDocumentsApplication.GetDetailsForClient(command.EmployeeId, _workshopId);
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = result.IsSuccedded,
|
|
message = result.Message,
|
|
imageSrc = employeeDocument
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostRemoveEmployeeDocumentByLabel(long employeeId, DocumentItemLabel label)
|
|
{
|
|
var result = _employeeDocumentsApplication.DeleteEmployeeMultipleUnsubmittedDocumentsByLabel(_workshopId, employeeId,
|
|
label);
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = result.IsSuccedded,
|
|
message = result.Message
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostSaveSubmit(SubmitEmployeeDocuments cmd)
|
|
{
|
|
var result = _employeeDocumentsApplication.SubmitDocumentItemsByClient(cmd);
|
|
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = result.IsSuccedded,
|
|
message = result.Message,
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostCancelOperation(long employeeId)
|
|
{
|
|
var result = _employeeDocumentsApplication.DeleteUnsubmittedItems(_workshopId, employeeId);
|
|
return new JsonResult(new
|
|
{
|
|
success = 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 OnPostGroupSave(long employeeId, List<AddEmployeeDocumentItem> command)
|
|
{
|
|
var result = _employeeDocumentsApplication.AddRangeEmployeeDocumentItemsByClient(_workshopId, employeeId, command);
|
|
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = result.IsSuccedded,
|
|
message = result.Message,
|
|
});
|
|
}
|
|
}
|
|
}
|