Only show active contract area
This commit is contained in:
@ -10,6 +10,9 @@ using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace Elwig.Helpers {
|
||||
public static class Utils {
|
||||
|
||||
public static int CurrentSeason => DateTime.Now.Year - (DateTime.Now.Month <= 3 ? 1 : 0);
|
||||
|
||||
public static void SetInputChanged(Control input) {
|
||||
var brush = Brushes.Orange;
|
||||
if (input is ComboBox cb) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Elwig.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -144,6 +145,11 @@ namespace Elwig.Models {
|
||||
[InverseProperty("Member")]
|
||||
public virtual ISet<Contract> Contracts { get; private set; }
|
||||
|
||||
[NotMapped]
|
||||
public virtual ISet<Contract> ActiveContracts => Contracts
|
||||
.Where(c => c.YearFrom <= Utils.CurrentSeason && (c.YearTo ?? int.MaxValue) >= Utils.CurrentSeason)
|
||||
.ToHashSet();
|
||||
|
||||
[InverseProperty("Member")]
|
||||
public virtual BillingAddr BillingAddress { get; private set; }
|
||||
|
||||
|
@ -387,7 +387,7 @@ namespace Elwig.Windows {
|
||||
case "email": ContactEmailInput.IsChecked = true; break;
|
||||
}
|
||||
|
||||
AreaCommitment.Text = $"{m.Contracts.Select(c => c.Area).Sum():N0} m²";
|
||||
AreaCommitment.Text = $"{m.ActiveContracts.Select(c => c.Area).Sum():N0} m²";
|
||||
|
||||
Menu_Member_SendEmail.IsEnabled = m.Email != null;
|
||||
|
||||
|
Reference in New Issue
Block a user