From be1e9f941b7a16bf90bd77d8f56810f1ceabb663 Mon Sep 17 00:00:00 2001 From: "titouan.louvet" Date: Tue, 6 Jun 2023 11:36:10 +0200 Subject: [PATCH] Added transaction --- src/Banquale/Model/Transaction.cs | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/Banquale/Model/Transaction.cs diff --git a/src/Banquale/Model/Transaction.cs b/src/Banquale/Model/Transaction.cs new file mode 100644 index 0000000..96645d1 --- /dev/null +++ b/src/Banquale/Model/Transaction.cs @@ -0,0 +1,110 @@ +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace Model +{ + [DataContract(IsReference = true)] + public class Transactions : INotifyPropertyChanged + { + + void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + [DataMember(Order = 1)] + public int Id { get; private set; } + + [DataMember(Order = 2)] + public bool Type + { + get => type; + set + { + if(type == value) + return; + type = value; + OnPropertyChanged(nameof(Type)); + } + } + [DataMember] + + private bool type; + + [DataMember(Order = 3)] + public double Sum + { + get => sum; + set + { + if (sum == value) + return; + sum = value; + OnPropertyChanged(nameof(Sum)); + } + } + [DataMember] + private double sum; + + [DataMember(Order = 4)] + public Account InvolvedAccounts + { + get => involvedAccounts; + set + { + if (involvedAccounts == value) + return; + involvedAccounts = value; + OnPropertyChanged(nameof(InvolvedAccounts)); + } + } + [DataMember] + private Account involvedAccounts; + + [DataMember(Order = 5)] + public string Category + { + get => category; + set + { + if (category == value) + return; + category = value; + OnPropertyChanged(nameof(Category)); + } + } + [DataMember] + private string? category; + + [DataMember(Order = 6)] + public DateTime Date + { + get => date; + set + { + if (date == value) + return; + date = value; + OnPropertyChanged(nameof(Date)); + } + } + [DataMember] + private DateTime date; + + public Transactions(bool type, double sum, Account involvedAccounts/*, string category*/, int id, DateTime date) + { + Type = type; + Sum = sum; + Id = id; + InvolvedAccounts = involvedAccounts; + //Category = category; + Date = date; + } + + public void ChangeCategory(string newCateg) + { + Category = newCateg; + } + + public event PropertyChangedEventHandler? PropertyChanged; + } +}