private DateTime calculateDateForEvent(MasterActivity a, DateTime fromDate) { var calendarDate = fromDate.AddDays(-(int)fromDate.DayOfWeek + a.DateOfWeek); if (calendarDate < fromDate) { calendarDate = calendarDate.AddDays(7); } return(new DateTime(calendarDate.Year, calendarDate.Month, calendarDate.Day, a.Hour, a.Minutes, 0)); }
private DateTime calculateDateForEvent(MasterActivity a) { int restWeek = 0; if (DateTime.Today.DayOfWeek == DayOfWeek.Sunday) { restWeek = -1; } var calendarDate = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + a.DateOfWeek); calendarDate = calendarDate.AddDays(7 * restWeek); return(new DateTime(calendarDate.Year, calendarDate.Month, calendarDate.Day, a.Hour, a.Minutes, 0)); }