PI2024-23 #2
@ -96,9 +96,6 @@ namespace FirmTracker_Server.Controllers
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
@ -119,6 +116,33 @@ namespace FirmTracker_Server.Controllers
|
||||
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]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(404)]
|
||||
|
@ -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)
|
||||
{
|
||||
using (var session = SessionFactory.OpenSession())
|
||||
|
Loading…
Reference in New Issue
Block a user