Files
Backend-Api/ServiceHost/Areas/Admin/Pages/Company/Insurance/Index.cshtml.cs
2024-07-19 17:09:45 +03:30

160 lines
4.3 KiB
C#

using _0_Framework.Application;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.Insurance;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace ServiceHost.Areas.Admin.Pages.Company.Insurance;
//public class InsuranceSearchModel
//{
// public long Id { get; set; }
// public int Year { get; set; }
// public string Month { get; set; }
// public string Employer { get; set; }
// public string WorkShop { get; set; }
//}
public class InsuranceViewModel
{
public long Id { get; set; }
public int Year { get; set; }
public string Month { get; set; }
public string Employer { get; set; }
public string WorkShop { get; set; }
public string Qouta { get; set; }
public string InsuranceCode { get; set; }
public string InsuranceBranch { get; set; }
public string City { get; set; }
public string Fixed { get; set; }
}
[Authorize]
public class IndexModel : PageModel
{
public static string[] MonthNames =
{ "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" };
private readonly IEmployerApplication _employerApplication;
private readonly IInsuranceApplication _insuranceApplication;
private readonly IWorkshopApplication _workShopApplication;
public List<InsuranceViewModel> insurance;
public InsuranceSearchModel searchModel;
public IndexModel(IInsuranceApplication insuranceApplication, IEmployerApplication employerApplication,
IWorkshopApplication workShopApplication)
{
_insuranceApplication = insuranceApplication;
_employerApplication = employerApplication;
_workShopApplication = workShopApplication;
}
public void OnGet(InsuranceSearchModel searchModel)
{
var item1 =
new InsuranceViewModel
{
Id = 1,
Year = 1401,
Month = "مهر",
InsuranceCode = "10232156",
InsuranceBranch = "شعبه 9",
Employer = "شکوفه موتور گیلان",
WorkShop = "شکوفه موتور گیلان تهران",
Qouta = "عادی",
City = "تهران",
Fixed = "مقطوع"
};
var item2 =
new InsuranceViewModel
{
Id = 2,
Year = 1401,
Month = "مهر",
InsuranceCode = "102654498",
InsuranceBranch = "شعبه 3",
Employer = "محمد حق پرست",
WorkShop = "تولیدی درب و پنجره",
Qouta = "کمک دولتی",
City = "رشت",
Fixed = "-"
};
insurance = new List<InsuranceViewModel>();
insurance.Add(item1);
insurance.Add(item2);
}
public IActionResult OnGetCreate()
{
var createInsurance = new CreateInsurance();
createInsurance.EmployerList = new SelectList(_employerApplication.GetEmployers(), "Id", "FullName");
createInsurance.Year = Convert.ToInt32(DateTime.Now.ToFarsiYear());
createInsurance.Month = Convert.ToInt32(DateTime.Now.ToFarsiMonth()) == 1
? 12
: Convert.ToInt32(DateTime.Now.ToFarsiMonth()) - 1;
return Partial("./Create", createInsurance);
}
public IActionResult OnGetSubtitleList(long employerId)
{
var searchModel = new WorkshopSearchModel();
var subtitleList = _workShopApplication.Search(new WorkshopSearchModel { EmployerId = employerId }).ToList();
return new JsonResult(subtitleList);
}
public IActionResult OnGetLastInsurance(long workShopId)
{
var query = _insuranceApplication.Search(new InsuranceSearchModel { WorkShopId = workShopId }).Select(x => new
{
x.EmployerStr,
x.WorkShopStr,
x.ListNumber,
x.Address,
WorkShopCode = x.Workshop.ArchiveCode,
RadifPeyman = x.Workshop.Id
}).LastOrDefault();
return new JsonResult(query);
}
//public IActionResult OnGetSummary()
//{
// return Partial("./Summary");
//}
//public IActionResult OnPostCreate(CreateCrossJobGuild command)
//{
//}
//public IActionResult OnGetEdit(long id)
//{
//}
//public JsonResult OnPostEdit(EditCrossJobGuild command)
//{
//}
//public IActionResult OnGetDetails(long id)
//{
// var detail = _crossJobGuildApplication.GetDetails(id);
// return Partial("Details", detail);
//}
//public IActionResult OnPostRemove(long id)
//{
// var result = new OperationResult();
// return new JsonResult(result);
//}
}