private DateTime GetStarTime() { if (!Talks.Any()) { return(startTime); } var lastTalk = Talks.OrderByDescending(x => x.StarTime).First(); return(lastTalk.StarTime.Value.AddMinutes(lastTalk.Duration)); }
public void AddTalkInSpecificTime(DateTime startTimeMin, DateTime startTimeMax, Talk talk) { if (!Talks.Any()) { talk.StarTime = startTimeMin; Talks.Add(talk); return; } var lastTalk = Talks.OrderByDescending(x => x.StarTime).First(); if (lastTalk.StarTime.Value.AddMinutes(lastTalk.Duration) <= startTimeMin) { talk.StarTime = startTimeMin; Talks.Add(talk); return; } talk.StarTime = lastTalk.StarTime.Value.AddMinutes(lastTalk.Duration) < startTimeMax?lastTalk.StarTime.Value.AddMinutes(lastTalk.Duration) : startTimeMax; Talks.Add(talk); }