public FondDecorator(IFond component) { if (component.Members != null) { Members = component.Members; } else { Members = new List <IAccount>(); } _component = component; }
public IResult MakeContribution(IFond fond, IBalance balance) { IResult result = Result.GetDefaultResult(); if (fond.HasMember(this).Success) { ITransaction accountSpending = new Transaction(); accountSpending.Name = TransactionNameHolder .GetName(TransactionName.FondSpending); accountSpending.Description = string.Format("{0} - {1}", fond.Name, balance.GetStrValue()); accountSpending.Type = new TransactionType(TransactionTypes .Spending.ToString()); accountSpending.Time = DateTime.Now.ToLongTimeString(); accountSpending.Amount = balance; ITransaction fondEarning = new Transaction(); fondEarning.Name = TransactionNameHolder .GetName(TransactionName.AccountContribution); fondEarning.Description = string.Format("{0} - {1}", this.Name, balance.GetStrValue()); fondEarning.Type = new TransactionType(TransactionTypes .Earning.ToString()); fondEarning.Time = DateTime.Now.ToLongTimeString(); fondEarning.Amount = balance; this.SpendMoney(accountSpending); fond.ReceiveMoney(fondEarning); result.Success = true; result.Message = string.Format(MessageHolder .GetMessage(MessageType.MakeContribution), this.Name, fond.Name); } else { result.Message = fond.HasMember(this).Message; } return(result); }
public IResult JoinToFond(IFond fond) { IResult result = Result.GetDefaultResult(); if (fond != null) { Fonds.Add(fond); fond.AddMember(this); result.Success = true; result.Message = string.Format(MessageHolder .GetMessage(MessageType.FondJoin), this.Name, fond.Name); } else { result.Message = string.Format(MessageHolder .GetMessage(MessageType.CanntJoin), fond.Name); } return(result); }
public FamilyFond(IFond component) : base(component) { FondType = "Family fond"; }