PI2024-23 #2

Merged
s464958 merged 21 commits from PI2024-23 into master 2024-06-14 14:47:25 +02:00
9 changed files with 30 additions and 4 deletions
Showing only changes of commit 812ee1b8eb - Show all commits

View File

@ -1,4 +1,6 @@
namespace FirmTracker_Server.nHibernate.Expenses using FirmTracker_Server.nHibernate.Reports;
namespace FirmTracker_Server.nHibernate.Expenses
{ {
public class Expense public class Expense
{ {
@ -6,5 +8,6 @@
public virtual DateTime Date { get; set; } public virtual DateTime Date { get; set; }
public virtual decimal Value { get; set; } public virtual decimal Value { get; set; }
public virtual string Description { get; set; } public virtual string Description { get; set; }
public virtual IList<Report> Reports { get; set; } = new List<Report>();
} }
} }

View File

@ -12,6 +12,12 @@ namespace FirmTracker_Server.nHibernate.Expenses
Map(x => x.Value); Map(x => x.Value);
Map(x => x.Description); Map(x => x.Description);
HasManyToMany(x => x.Reports)
.Cascade.All()
.Table("ReportExpenses")
.ParentKeyColumn("ExpenseId")
.ChildKeyColumn("ReportId");
} }
} }
} }

View File

@ -1,7 +1,7 @@
using FirmTracker_Server.nHibernate.Expenses; using FirmTracker_Server.nHibernate.Expenses;
using FirmTracker_Server.nHibernate.Transactions; using FirmTracker_Server.nHibernate.Transactions;
namespace FirmTracker_Server.nHIbernate.Reports namespace FirmTracker_Server.nHibernate.Reports
{ {
public class Report public class Report
{ {

View File

@ -1,5 +1,5 @@
using FluentNHibernate.Mapping; using FluentNHibernate.Mapping;
namespace FirmTracker_Server.nHIbernate.Reports namespace FirmTracker_Server.nHibernate.Reports
{ {
public class ReportMapping : ClassMap<Report> public class ReportMapping : ClassMap<Report>
{ {

View File

@ -33,7 +33,8 @@ namespace FirmTracker_Server.nHibernate
.AddFromAssemblyOf<Transactions.TransactionProductMapping>() .AddFromAssemblyOf<Transactions.TransactionProductMapping>()
.AddFromAssemblyOf<Transactions.Transaction2Mapping>() .AddFromAssemblyOf<Transactions.Transaction2Mapping>()
.AddFromAssemblyOf<Transactions.TransactionWithProductsMapping>() .AddFromAssemblyOf<Transactions.TransactionWithProductsMapping>()
.AddFromAssemblyOf<Expenses.ExpenseMapping>(); .AddFromAssemblyOf<Expenses.ExpenseMapping>()
.AddFromAssemblyOf<Reports.ReportMapping>();
}) })
.ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true)) //SchemaUpdate . Execute dla only update .ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true)) //SchemaUpdate . Execute dla only update
.BuildSessionFactory(); .BuildSessionFactory();

View File

@ -1,4 +1,5 @@
using FirmTracker_Server.nHibernate.Products; using FirmTracker_Server.nHibernate.Products;
using FirmTracker_Server.nHibernate.Reports;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -15,6 +16,7 @@ namespace FirmTracker_Server.nHibernate.Transactions
public virtual decimal Discount { get; set; } public virtual decimal Discount { get; set; }
public virtual string Description { get; set; } public virtual string Description { get; set; }
public virtual decimal TotalPrice { get; set; }//=> TransactionProducts.Sum(tp => ((tp.Quantity * tp.UnitPrice)* ((1 - (Discount / 100)))));// (1 - (Discount / 100))); public virtual decimal TotalPrice { get; set; }//=> TransactionProducts.Sum(tp => ((tp.Quantity * tp.UnitPrice)* ((1 - (Discount / 100)))));// (1 - (Discount / 100)));
public virtual IList<Report> Reports { get; set; } = new List<Report>();
public Transaction() public Transaction()
{ {

View File

@ -1,4 +1,5 @@
using FirmTracker_Server.nHibernate.Products; using FirmTracker_Server.nHibernate.Products;
using FirmTracker_Server.nHibernate.Reports;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -15,6 +16,7 @@ namespace FirmTracker_Server.nHibernate.Transactions
public virtual decimal Discount { get; set; } public virtual decimal Discount { get; set; }
public virtual string Description { get; set; } public virtual string Description { get; set; }
public virtual decimal TotalPrice { get; set; }//=> TransactionProducts.Sum(tp => ((tp.Quantity * tp.UnitPrice)* ((1 - (Discount / 100)))));// (1 - (Discount / 100))); public virtual decimal TotalPrice { get; set; }//=> TransactionProducts.Sum(tp => ((tp.Quantity * tp.UnitPrice)* ((1 - (Discount / 100)))));// (1 - (Discount / 100)));
public virtual IList<Report> Reports { get; set; } = new List<Report>();
public Transaction2() public Transaction2()
{ {

View File

@ -18,6 +18,12 @@ namespace FirmTracker_Server.nHibernate.Transactions
.KeyColumn("TransactionId") .KeyColumn("TransactionId")
.Cascade.AllDeleteOrphan() .Cascade.AllDeleteOrphan()
.Inverse(); // Ustawienie Inverse() wskazuje, że to `TransactionProduct` jest właścicielem relacji .Inverse(); // Ustawienie Inverse() wskazuje, że to `TransactionProduct` jest właścicielem relacji
HasManyToMany(x => x.Reports)
.Cascade.All()
.Table("ReportTransactions")
.ParentKeyColumn("TransactionId")
.ChildKeyColumn("ReportId");
} }
} }
} }

View File

@ -18,6 +18,12 @@ namespace FirmTracker_Server.nHibernate.Transactions
.KeyColumn("TransactionId") .KeyColumn("TransactionId")
.Cascade.AllDeleteOrphan() .Cascade.AllDeleteOrphan()
.Inverse(); // Ustawienie Inverse() wskazuje, że to `TransactionProduct` jest właścicielem relacji .Inverse(); // Ustawienie Inverse() wskazuje, że to `TransactionProduct` jest właścicielem relacji
HasManyToMany(x => x.Reports)
.Cascade.All()
.Table("ReportTransactions")
.ParentKeyColumn("TransactionId")
.ChildKeyColumn("ReportId");
} }
} }
} }