using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace bnhtrade.Core.Model.Account { public class Journal : IValidatableObject { internal Journal(int journalId, Core.Model.Account.JournalType type, List posts, DateTime entryDate, DateTime postDate, DateTime lastModifed, bool isLocked) { JournalId = journalId; Type = type; Posts = posts; EntryDate = entryDate; PostDate = postDate; LastModified = lastModifed; IsLocked = isLocked; } public int JournalId { get; private set; } public Core.Model.Account.JournalType Type { get; private set; } public List Posts { get; private set; } = new List(); public DateTime EntryDate { get; private set; } public DateTime PostDate { get; private set; } public DateTime LastModified { get;private set; } public bool IsLocked { get; private set; } public class Post { internal Post(int postId, Core.Model.Account.Account account, decimal amountGbp) { PostId = postId; Account = account; AmountGbp = amountGbp; } public int PostId { get; private set; } public Core.Model.Account.Account Account { get; private set; } public decimal AmountGbp { get; private set; } } public IEnumerable Validate(ValidationContext validationContext) { var result = new List(); // get total of posts decimal postTotal = 0; foreach (var post in Posts) { postTotal = postTotal + post.AmountGbp; } if (postTotal != 0) { result.Add(new ValidationResult("Account journal posts do not equal zero")); } throw new NotImplementedException(); return result; } } }