Compare commits
7 Commits
Feature/sa
...
Feature/lo
| Author | SHA1 | Date | |
|---|---|---|---|
| fa4c39904a | |||
| 0e7787dd56 | |||
| 87c3cebb60 | |||
| 607c0780b6 | |||
| ef49302f8a | |||
| 4ab9f60932 | |||
| 9cfae54db3 |
@@ -21,6 +21,6 @@ public class LoanGroupedViewModel
|
||||
{
|
||||
public List<LoanGroupedByDateViewModel> GroupedByDate { get; set; }
|
||||
public List<LoanGroupedByEmployeeViewModel>GroupedByEmployee { get; set; }
|
||||
public List<LoanViewModel> LoanListViewModel { get; set; }
|
||||
public PagedResult<LoanViewModel> LoanListViewModel { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -16,5 +16,6 @@ public class LoanSearchViewModel
|
||||
public string EndDate { get; set; }
|
||||
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; } = 30;
|
||||
public bool ShowAsGrouped { get; set; }
|
||||
}
|
||||
|
||||
@@ -171,22 +171,29 @@ public class LoanRepository : RepositoryBase<long, Loan>, ILoanRepository
|
||||
query = query.Where(x => x.StartInstallmentPayment >= startDate && x.StartInstallmentPayment <= endDate);
|
||||
}
|
||||
|
||||
result.LoanListViewModel = query.OrderByDescending(x => x.StartInstallmentPayment).Skip(searchModel.PageIndex)
|
||||
.Take(30).ToList()
|
||||
.Select(x => new LoanViewModel()
|
||||
{
|
||||
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
||||
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountPerMonth = x.AmountPerMonth.ToMoney(),
|
||||
StartDateTime = x.StartInstallmentPayment.ToFarsi(),
|
||||
Count = x.Count,
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
EmployeeId = x.EmployeeId,
|
||||
YearFa = pc.GetYear(x.StartInstallmentPayment).ToString(),
|
||||
result.LoanListViewModel = new PagedResult<LoanViewModel>()
|
||||
{
|
||||
TotalCount = query.Count(),
|
||||
List = query.OrderByDescending(x => x.StartInstallmentPayment)
|
||||
.ApplyPagination(searchModel.PageIndex, searchModel.PageSize)
|
||||
.Take(30).ToList()
|
||||
.Select(x => new LoanViewModel()
|
||||
{
|
||||
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
||||
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode
|
||||
.ToString(),
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountPerMonth = x.AmountPerMonth.ToMoney(),
|
||||
StartDateTime = x.StartInstallmentPayment.ToFarsi(),
|
||||
Count = x.Count,
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
EmployeeId = x.EmployeeId,
|
||||
YearFa = pc.GetYear(x.StartInstallmentPayment).ToString(),
|
||||
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
}).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
59
ServiceHost/Areas/Client/Controllers/LoanController.cs
Normal file
59
ServiceHost/Areas/Client/Controllers/LoanController.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using CompanyManagment.App.Contracts.Loan;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers;
|
||||
|
||||
public class LoanController: ClientBaseController
|
||||
{
|
||||
private readonly ILoanApplication _loanApplication;
|
||||
private readonly long _workshopId;
|
||||
|
||||
public LoanController(ILoanApplication loanApplication, IAuthHelper authHelper)
|
||||
{
|
||||
_loanApplication = loanApplication;
|
||||
_workshopId= authHelper.GetWorkshopId();
|
||||
}
|
||||
[HttpGet]
|
||||
public ActionResult<LoanGroupedViewModel> GetList(LoanSearchViewModel searchModel)
|
||||
{
|
||||
searchModel.WorkshopId = _workshopId;
|
||||
var loans = _loanApplication.GetSearchListAsGrouped(searchModel);
|
||||
return loans;
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<LoanDetailsViewModel>> GetDetails(long id)
|
||||
{
|
||||
var loan = await _loanApplication.GetDetails(id);
|
||||
return loan;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult<OperationResult> Create([FromBody] CreateLoanViewModel command)
|
||||
{
|
||||
var result = _loanApplication.Create(command);
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet("create/installments")]
|
||||
public ActionResult<List<LoanInstallmentViewModel>> CalculateLoanInstallment(string amount,
|
||||
int installmentCount, string loanStartDate, bool getRounded)
|
||||
{
|
||||
var installments =
|
||||
_loanApplication.CalculateLoanInstallment(amount, installmentCount, loanStartDate, getRounded);
|
||||
return installments;
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public ActionResult<OperationResult> Remove(long id)
|
||||
{
|
||||
var result = _loanApplication.Remove(id);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user