lab_4 complete

This commit is contained in:
2025-04-10 09:07:45 +04:00
parent 5e249e488c
commit fddb9c9d83
37 changed files with 1786 additions and 178 deletions

View File

@@ -57,22 +57,17 @@ internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageC
{
_logger.LogInformation("CalculateSalaryByMounth: {date}", date);
var startDate = new DateTime(date.Year, date.Month, 1);
var finishDate = new DateTime(date.Year, date.Month,
DateTime.DaysInMonth(date.Year, date.Month));
var workers = _workerStorageContract.GetList() ?? throw new
NullListException();
var finishDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));
var workers = _workerStorageContract.GetList() ?? throw new NullListException();
foreach (var worker in workers)
{
var requests = _requestStorageContract.GetList(startDate,
finishDate, workerId: worker.Id)?.Sum(x => x.Sum) ??
throw new NullListException();
var post = _postStorageContract.GetElementById(worker.PostId)
??
throw new NullListException();
var requests = _requestStorageContract.GetList(startDate, finishDate, workerId: worker.Id)?.Sum(x => x.Sum) ??
throw new NullListException();
var post = _postStorageContract.GetElementById(worker.PostId) ??
throw new NullListException();
var salary = post.Salary + requests * 0.1;
_logger.LogDebug("The employee {workerId} was paid a salary of { salary} ", worker.Id, salary);
_salaryStorageContract.AddElement(new
SalaryDataModel(worker.Id, finishDate, salary));
_logger.LogDebug("The employee {workerId} was paid a salary of {salary}", worker.Id, salary);
_salaryStorageContract.AddElement(new SalaryDataModel(worker.Id, finishDate, salary));
}
}
}