/// <summary> /// Constructor for any transaction /// </summary> /// <param name="date"></param> /// <param name="description"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="code"></param> /// <param name="amount"></param> /// <param name="notes"></param> public Transaction(Date date, Time time, TimeZoneInfo zone, String description, Contact.PaymentAccount from, Contact.PaymentAccount to, Transaction.Code code, Decimal amount, String currency, String transactionId, String notes) : base() { this.Date = date; this.Time = time; this.TimeZone = zone; this.Description = description; this.From = from; this.To = to; this.Type = code; this.Amount = amount; this.Currency = currency; this.TransactionId = transactionId ?? String.Empty; this.Note = notes ?? String.Empty; }
/// <summary> /// Unlinks a contact /// </summary> /// <param name="link"></param> public void UnlinkContact(Contact link) { var refLink = new MongoDBRef(link.GetCollection().Name, link.Id); var refThis = new MongoDBRef(this.GetCollection().Name, this.Id); foreach (var reference in this.LinkedContacts) Contact.UnlinkContact(reference.Id, refLink); foreach (var reference in link.LinkedContacts) Contact.UnlinkContact(reference.Id, refThis); //if (this.LinkedContacts.All(reference => !MongoDBRef.ReferenceEquals(refLink, reference)) UnlinkContact(refLink); link.UnlinkContact(refThis); }
/// <summary> /// Links a contact /// </summary> /// <param name="link"></param> public void LinkContact(Contact link) { var refLink = new MongoDBRef(link.GetCollection().Name, link.Id); var refThis = new MongoDBRef(this.GetCollection().Name, this.Id); // Add link to all this references foreach (var reference in this.LinkedContacts) { if (reference.Id == link.Id) continue; Contact.LinkContact(reference.Id, refLink); link.LinkContact(reference); } // Add this to all link references foreach (var reference in link.LinkedContacts) { Contact.LinkContact(reference.Id, refThis); } // // Add link to this LinkContact(refLink); // Add this to link link.LinkContact(refThis); }