private ScheduleBlock SeparateSection(ScheduleBlock block, ISplitRule splitRule) { var segments = new List <ScheduleSegment>(); foreach (var segment in block.ScheduleSegments) { segments.AddRange(splitRule.Split(segment)); } block.ScheduleSegments = segments; return(block); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="party"></param> public PartyDetailViewModel(Party party = null, ISplitRule rule = null) { Title = party?.Name; Party = party; // 支払額計算 SplitRule = rule ?? new DefaultSplitRule(); Bills = SplitRule.CalculateAmountAsync(Party).Result; // 端数計算 int totalAmount = 0; foreach (var bill in Bills) { int amount = bill.Amount; var payer = Party.Attendees.Where(item => item.Grade == bill.Grade).FirstOrDefault(); int num = payer.TotalCount - payer.GuestCount; totalAmount += amount * num; } Fraction = Party.TotalFee - totalAmount; }