200 lines
5.9 KiB
C#
200 lines
5.9 KiB
C#
using CompanyManagment.App.Contracts.DateSalary;
|
|
using CompanyManagment.App.Contracts.InsuranceJob;
|
|
using CompanyManagment.App.Contracts.Job;
|
|
using CompanyManagment.App.Contracts.Percentage;
|
|
using CompanyManagment.App.Contracts.YearlySalary;
|
|
using MD.PersianDateTime.Standard;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
namespace ServiceHost.Areas.Admin.Pages.Company.InsuranceJob;
|
|
|
|
public class IndexModel : PageModel
|
|
{
|
|
private readonly IDateSalaryApplication _dateSalaryApplication;
|
|
|
|
private readonly IInsuranceJobApplication _insuranceJobApplication;
|
|
|
|
//public SelectList Jobs;
|
|
private readonly IJobApplication _jobApplication;
|
|
private readonly IPercentageApplication _percentageApplication;
|
|
private readonly IYearlySalaryApplication _yearlySalaryApplication;
|
|
public List<InsuranceJobViewModel> InsuranceJobList;
|
|
public InsuranceJobSearchModel SearchModel;
|
|
public List<string> YearlyList;
|
|
|
|
public IndexModel(IJobApplication jobApplication, IInsuranceJobApplication insuranceJobApplication,
|
|
IYearlySalaryApplication yearlySalaryApplication, IPercentageApplication percentageApplication,
|
|
IDateSalaryApplication dateSalaryApplication)
|
|
{
|
|
_jobApplication = jobApplication;
|
|
_insuranceJobApplication = insuranceJobApplication;
|
|
_yearlySalaryApplication = yearlySalaryApplication;
|
|
_percentageApplication = percentageApplication;
|
|
_dateSalaryApplication = dateSalaryApplication;
|
|
}
|
|
|
|
public void OnGet(InsuranceJobSearchModel searchModel)
|
|
{
|
|
if(!string.IsNullOrWhiteSpace(searchModel.Year))
|
|
Console.WriteLine(searchModel.Year);
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Month))
|
|
Console.WriteLine(searchModel.Month);
|
|
YearlyList = _yearlySalaryApplication.GetYears();
|
|
|
|
var insuranceJobs = _insuranceJobApplication.Search(searchModel);
|
|
InsuranceJobList = insuranceJobs;
|
|
}
|
|
|
|
public IActionResult OnGetCreate()
|
|
{
|
|
var model = new CreateInsuranceJob
|
|
{
|
|
// Jobs = _jobApplication.GetJob()
|
|
};
|
|
return Partial("./Create", model);
|
|
}
|
|
|
|
public IActionResult OnPostCreate(CreateInsuranceJob command)
|
|
{
|
|
var result = _insuranceJobApplication.Create(command);
|
|
return new JsonResult(result);
|
|
}
|
|
|
|
public IActionResult OnGetCopyFromLastYear()
|
|
{
|
|
var dats = _insuranceJobApplication.GetOldYersInsuranceItemIds()
|
|
.Select(x => new { Id = x.id, Date = x.date })
|
|
.ToList();
|
|
var model = new CopyFromLastYearViewModel()
|
|
{
|
|
InsuranceJobItemId = 0,
|
|
StartDate = "",
|
|
EndDate = "",
|
|
InsuranceJobItemViewModels = new SelectList(dats,"Id", "Date"),
|
|
};
|
|
return Partial("./CopyFromLastYear", model);
|
|
}
|
|
public IActionResult OnPostCopyFromLastYear(CopyFromLastYearViewModel commnad)
|
|
{
|
|
var res = _insuranceJobApplication.CopyFromLastYear(commnad);
|
|
return new JsonResult(res);
|
|
}
|
|
|
|
//public async Task<IActionResult> OnPostJobListByText(string textSearch)
|
|
//{
|
|
// var jobs = _jobApplication.GetJobListByText(textSearch);
|
|
// return new JsonResult(new
|
|
// {
|
|
// IsSuccedded = true,
|
|
// mylist = jobs,
|
|
// });
|
|
//}
|
|
|
|
public IActionResult OnPostJobListByText(string textSearch)
|
|
{
|
|
var jobs = _jobApplication.GetJobListByText(textSearch);
|
|
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true,
|
|
jobList = jobs
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostJobListToWorkshop(string textSearch)
|
|
{
|
|
var searchjobList = new List<JobListViewModel>();
|
|
if (!string.IsNullOrWhiteSpace(textSearch) && textSearch.Length > 1)
|
|
{
|
|
var jobs = _jobApplication.GetJobListByText(textSearch);
|
|
searchjobList = jobs.Select(x => new JobListViewModel
|
|
{
|
|
Id = x.Id,
|
|
JobName = x.JobName
|
|
}).OrderBy(x => x.JobName.Length).Take(100).ToList();
|
|
}
|
|
|
|
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true,
|
|
jobList = searchjobList
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetDetails(long id, string year, string month)
|
|
{
|
|
var details = _insuranceJobApplication.GetDetails(id, year, month);
|
|
return Partial("Details", details);
|
|
}
|
|
|
|
public IActionResult OnGetCreateInformation()
|
|
{
|
|
var searchModel = new PercentageSearchModel();
|
|
var list = _percentageApplication.Search(searchModel);
|
|
return Partial("CreateInformation", list);
|
|
}
|
|
|
|
public IActionResult OnPostBeforeDate(string date)
|
|
{
|
|
var persianBefore = "";
|
|
var year = Convert.ToInt32(date.Substring(0, 4));
|
|
var month = Convert.ToInt32(date.Substring(5, 2));
|
|
var day = Convert.ToInt32(date.Substring(8, 2));
|
|
var persianDate = new PersianDateTime(year, month, day);
|
|
var persianBeforeDate = persianDate.AddDays(-1);
|
|
persianBefore = persianBeforeDate.ToString("yyyy/MM/dd");
|
|
|
|
return new JsonResult(new
|
|
{
|
|
ResultDate = persianBefore
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostAfterDate(string date)
|
|
{
|
|
var persianAfter = "";
|
|
var year = Convert.ToInt32(date.Substring(0, 4));
|
|
var month = Convert.ToInt32(date.Substring(5, 2));
|
|
var day = Convert.ToInt32(date.Substring(8, 2));
|
|
|
|
var persianDate = new PersianDateTime(year, month, day);
|
|
var persianAfterDate = persianDate.AddDays(1);
|
|
persianAfter = persianAfterDate.ToString("yyyy/MM/dd");
|
|
|
|
return new JsonResult(new
|
|
{
|
|
ResultDate = persianAfter
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostCreateDateSalaryItem(CreateDateSalaryForInsuranceJob command)
|
|
{
|
|
var result = _dateSalaryApplication.CreateDateSalaryItemForInsuranceJob(command);
|
|
return new JsonResult(result);
|
|
}
|
|
|
|
public IActionResult OnPostRemoveInsuranceJob(long id)
|
|
{
|
|
var result = _insuranceJobApplication.Remove(id);
|
|
return new JsonResult(result);
|
|
}
|
|
|
|
public IActionResult OnGetEdit(long id,string year, string month)
|
|
{
|
|
var model = new EditInsuranceJob();
|
|
model = _insuranceJobApplication.GetDetails(id, year, month);
|
|
model.Year = year;
|
|
model.Month = month;
|
|
return Partial("./Edit", model);
|
|
}
|
|
|
|
public IActionResult OnPostEdit(EditInsuranceJob command)
|
|
{
|
|
Console.WriteLine(command.Year);
|
|
var result = _insuranceJobApplication.Edit(command);
|
|
return new JsonResult(result);
|
|
}
|
|
} |