public HttpResponseMessage ActivitiesAndGroups(DateTimeOffset? fromTime, DateTimeOffset? toTime) { var timeline = new TimelineDto(); if (fromTime.HasValue && toTime.HasValue && fromTime < toTime) { var group = new GroupDto(); group.Color = HelperFunctions.GetRandomColor(); group.DisplayName = "My Group"; group.DisplayKey = "MyGroup"; group.GroupId = "1"; var activity = new ActivityDto(); activity.StartTime = new DateTimeOffset(fromTime.Value.Year, fromTime.Value.Month, fromTime.Value.Day, 12, 0, 0, fromTime.Value.Offset); activity.EndTime = activity.StartTime.AddHours(1); activity.DisplayName = "My activity"; activity.GroupId = group.GroupId; timeline.Activities = new[] { activity }; timeline.Groups = new[] { group }; timeline.Color = HelperFunctions.GetRandomColor(); } return new HttpResponseMessage() { Content = new StringContent(HelperFunctions.ToXml(timeline), Encoding.UTF8, "application/xml") }; }
public HttpResponseMessage OnlyTimes(DateTimeOffset? fromTime, DateTimeOffset? toTime) { var timeline = new TimelineDto(); if (fromTime.HasValue && toTime.HasValue && fromTime < toTime) { var activity = new ActivityDto(); activity.StartTime = new DateTimeOffset(fromTime.Value.Year, fromTime.Value.Month, fromTime.Value.Day, 12, 0, 0, fromTime.Value.Offset); activity.EndTime = activity.StartTime.AddHours(1); timeline.Activities = new[] { activity }; } return new HttpResponseMessage() { Content = new StringContent(HelperFunctions.ToXml(timeline), Encoding.UTF8, "application/xml") }; }