PI2024-23 #2
23
nHIbernate/Reports/Report.cs
Normal file
23
nHIbernate/Reports/Report.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using FirmTracker_Server.nHibernate.Expenses;
|
||||||
|
using FirmTracker_Server.nHibernate.Transactions;
|
||||||
|
|
||||||
|
namespace FirmTracker_Server.nHIbernate.Reports
|
||||||
|
{
|
||||||
|
public class Report
|
||||||
|
{
|
||||||
|
public virtual int Id { get; set; }
|
||||||
|
public virtual DateTime FromDate { get; set; }
|
||||||
|
public virtual DateTime ToDate { get; set; }
|
||||||
|
public virtual IList<Transaction> Transactions { get; set;} = new List<Transaction>();
|
||||||
|
public virtual IList<Expense> Expenses { get; set; } = new List<Expense>();
|
||||||
|
public virtual decimal TotalIncome { get; set; }
|
||||||
|
public virtual decimal TotalExpenses { get; set; }
|
||||||
|
public virtual decimal TotalBalance { get; set; }
|
||||||
|
public Report() {
|
||||||
|
Transactions = new List<Transaction>();
|
||||||
|
Expenses = new List<Expense>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
30
nHIbernate/Reports/ReportMapping.cs
Normal file
30
nHIbernate/Reports/ReportMapping.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using FluentNHibernate.Mapping;
|
||||||
|
namespace FirmTracker_Server.nHIbernate.Reports
|
||||||
|
{
|
||||||
|
public class ReportMapping : ClassMap<Report>
|
||||||
|
{
|
||||||
|
public ReportMapping()
|
||||||
|
{
|
||||||
|
Table("Reports");
|
||||||
|
Id(x => x.Id).GeneratedBy.Identity();
|
||||||
|
Map(x => x.FromDate);
|
||||||
|
Map(x => x.ToDate);
|
||||||
|
Map(x => x.TotalIncome);
|
||||||
|
Map(x => x.TotalExpenses);
|
||||||
|
Map(x => x.TotalBalance);
|
||||||
|
|
||||||
|
HasManyToMany(x => x.Transactions)
|
||||||
|
.Cascade.All()
|
||||||
|
.Table("ReportTransactions")
|
||||||
|
.ParentKeyColumn("ReportId")
|
||||||
|
.ChildKeyColumn("TransactionId");
|
||||||
|
|
||||||
|
HasManyToMany(x => x.Expenses)
|
||||||
|
.Cascade.All()
|
||||||
|
.Table("ReportExpenses")
|
||||||
|
.ParentKeyColumn("ReportId")
|
||||||
|
.ChildKeyColumn("ExpenseId");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user