PI2024-23 #2

Merged
s464958 merged 21 commits from PI2024-23 into master 2024-06-14 14:47:25 +02:00
2 changed files with 51 additions and 3 deletions
Showing only changes of commit a25a1a3d23 - Show all commits

View File

@ -96,9 +96,6 @@ namespace FirmTracker_Server.Controllers
return BadRequest(ex.Message); return BadRequest(ex.Message);
} }
} }
[HttpGet("{id}")] [HttpGet("{id}")]
@ -119,6 +116,33 @@ namespace FirmTracker_Server.Controllers
return Ok(json); return Ok(json);
} }
[HttpGet("{id}/transactions")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public IActionResult GetReportTransactions(int reportId)
{
var transactions = _reportCRUD.GetReportTransactions(reportId);
if (transactions == null)
{
return NotFound();
}
return Ok(transactions);
}
[HttpGet("{id}/expenses")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public IActionResult GetReportExpenses(int reportId)
{
var expenses = _reportCRUD.GetReportExpenses(reportId);
if (expenses == null)
{
return NotFound();
}
return Ok(expenses);
}
[HttpGet] [HttpGet]
[ProducesResponseType(200)] [ProducesResponseType(200)]
[ProducesResponseType(404)] [ProducesResponseType(404)]

View File

@ -99,6 +99,30 @@ namespace FirmTracker_Server.nHibernate.Reports
} }
} }
public IList<nHibernate.Transactions.Transaction> GetReportTransactions(int reportId)
{
using (var session = SessionFactory.OpenSession())
{
return session.Query<ReportTransaction>()
.Where(rt => rt.Report.Id == reportId)
.Select(rt => rt.Transaction)
.Fetch(t => t.TransactionProducts)
.ToList();
}
}
public IList<Expense> GetReportExpenses(int reportId)
{
using (var session = SessionFactory.OpenSession())
{
return session.Query<ReportExpense>()
.Where(re => re.Report.Id == reportId)
.Select(re => re.Expense)
.ToList();
}
}
public Report UpdateReport(Report report, IList<nHibernate.Transactions.Transaction> transactions, IList<Expense> expenses) public Report UpdateReport(Report report, IList<nHibernate.Transactions.Transaction> transactions, IList<Expense> expenses)
{ {
using (var session = SessionFactory.OpenSession()) using (var session = SessionFactory.OpenSession())