Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Ink;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Practices.Prism.ViewModel;
- using System.Data.Linq.Mapping;
- using System.ComponentModel;
- using System.Data.Linq;
- namespace Bick.Budget.Entities.Transactions
- {
- [Table(Name = "Transactions")]
- public class Transaction : NotificationObject
- {
- #region Fields
- /// <summary>
- /// Stores transaction id
- /// </summary>
- private Guid id;
- /// <summary>
- /// Stores transaction name
- /// </summary>
- private string name;
- /// <summary>
- /// Stores amount of transaction
- /// </summary>
- private double amount;
- /// <summary>
- /// Stores date when transaction was created
- /// </summary>
- private DateTime dateAdded;
- /// <summary>
- /// Stores date when transaction was marked as completed (paid/received)
- /// </summary>
- private DateTime? dateCompleted;
- /// <summary>
- /// Stores date when transaction is planned to be completed
- /// </summary>
- private DateTime? datePlanned;
- /// <summary>
- /// Stores parent category entity
- /// </summary>
- private EntityRef<Categories.Category> category;
- /// <summary>
- /// Stores parent category ID
- /// </summary>
- private Guid? categoryID;
- #endregion
- #region Constructors
- /// <summary>
- /// Default constructor for Transaction class
- /// </summary>
- public Transaction()
- {
- this.ID = Guid.NewGuid();
- this.DateAdded = DateTime.Now;
- }
- #endregion
- #region Properties
- #region Columns
- /// <summary>
- /// Gets transaction ID
- /// </summary>
- [Column(IsPrimaryKey = true)]
- public Guid ID
- {
- get
- {
- return this.id;
- }
- private set
- {
- if (this.id != value)
- {
- this.id = value;
- this.RaisePropertyChanged(() => this.ID);
- }
- }
- }
- /// <summary>
- /// Gets or sets transaction name
- /// </summary>
- [Column]
- public string Name
- {
- get
- {
- return this.name;
- }
- set
- {
- if (this.name != value)
- {
- this.name = value;
- this.RaisePropertyChanged(() => this.Name);
- }
- }
- }
- /// <summary>
- /// Gets or sets transaction amount
- /// </summary>
- [Column]
- [DefaultValue(0)]
- public double Amount
- {
- get
- {
- return this.amount;
- }
- set
- {
- if (this.amount != value)
- {
- this.amount = value;
- this.RaisePropertyChanged(() => this.Amount);
- }
- }
- }
- /// <summary>
- /// Gets date when transaction was created
- /// </summary>
- [Column]
- public DateTime DateAdded
- {
- get
- {
- return this.dateAdded;
- }
- private set
- {
- if (this.dateAdded != value)
- {
- this.dateAdded = value;
- this.RaisePropertyChanged(() => this.DateAdded);
- }
- }
- }
- /// <summary>
- /// Gets or sets date when transaction was marked as completed (paid/received)
- /// </summary>
- [Column(CanBeNull = true)]
- public DateTime? DateCompleted
- {
- get
- {
- return this.dateCompleted;
- }
- set
- {
- if (this.dateCompleted != value)
- {
- this.dateCompleted = value.Value;
- this.RaisePropertyChanged(() => this.DateCompleted);
- }
- }
- }
- /// <summary>
- /// Gets or sets date when transaction is planned to be completed
- /// </summary>
- [Column(CanBeNull = true)]
- public DateTime? DatePlanned
- {
- get
- {
- return this.datePlanned;
- }
- set
- {
- if (this.datePlanned != value)
- {
- this.datePlanned = value;
- this.RaisePropertyChanged(() => this.DatePlanned);
- }
- }
- }
- /// <summary>
- /// Gets parent category ID
- /// </summary>
- [Column(CanBeNull = true)]
- public Guid? CategoryID
- {
- get
- {
- return this.categoryID;
- }
- private set
- {
- if (this.categoryID != value)
- {
- this.categoryID = value;
- this.RaisePropertyChanged(() => this.categoryID);
- }
- }
- }
- #endregion
- /// <summary>
- /// Gets or sets parent Category
- /// </summary>
- [Association(Name = "FK_Transactions_Category", Storage = "category", ThisKey = "CategoryID", IsForeignKey = true)]
- public Categories.Category Category
- {
- get
- {
- return this.category.Entity;
- }
- set
- {
- Categories.Category previousValue = this.category.Entity;
- if (((previousValue != value) || (this.category.HasLoadedOrAssignedValue == false)))
- {
- if ((previousValue != null))
- {
- this.category.Entity = null;
- previousValue.Transactions.Remove(this);
- }
- this.category.Entity = value;
- if ((value != null))
- {
- if ((value.AddedTransactions == null) || (!value.AddedTransactions.Contains(this)))
- {
- value.Transactions.Add(this);
- }
- this.CategoryID = value.ID;
- }
- else
- {
- this.category = new EntityRef<Categories.Category>();
- }
- this.RaisePropertyChanged(() => this.Category);
- }
- }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement