예제 #1
0
        public static TaskTimeSpanService ToService(this TaskTimeSpan timeSpan, IStudyTasksService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            var task = service.GetTask(timeSpan.TaskId);

            if (task == null)
            {
                throw new ArgumentException($"A task with Id {timeSpan.TaskId} does not exist in the database", nameof(timeSpan));
            }

            return(new TaskTimeSpanService
            {
                Id = timeSpan.Id,
                Start = timeSpan.Start,
                End = timeSpan.End,
                TaskId = timeSpan.TaskId
            });
        }
예제 #2
0
 /// <summary> Creates a <see cref="StudyTask"/> instance representing an already existing task in the database. </summary>
 /// <param name="taskId"> The id of the task in the database to fetch. </param>
 public StudyTask(IStudyTasksService service, int taskId)
     : this(service, service.GetTask(taskId))
 {
     Contract.Assert(this.MessageObject.Id == taskId);
 }