예제 #1
0
        /// <summary>
        /// Adds newly created task to the <see cref="TimeTasksCalculator"/>
        /// </summary>
        public void AddNewTask()
        {
            // Check if we have everything we need for new task to create
            if (!ValidateUserInput())
            {
                // Display message to the user
                mUIManager.DisplayPopupMessageAsync(new PopupMessageViewModel(LocalizationResource.InvalidData, LocalizationResource.ProvidedTaskDataInvalid));

                // Stay at this page so user can correct his mistakes
                return;
            }

            // Data is correct, create new context out of it
            var newTask = new TimeTaskContext
            {
                Id              = TaskId,
                Name            = TaskName,
                Description     = TaskDescription,
                Tags            = TaskTagsString.SplitTagsString(),
                Type            = TaskType,
                AssignedTime    = TaskConstantTime,
                HasConstantTime = TaskHasConstantTime,
                IsImportant     = TaskImportance,
                IsImmortal      = TaskImmortality,
                Priority        = (Priority)TaskPrioritySliderValue,
                CreationDate    = DateTime.Now,
                SessionProgress = 0,
                Progress        = TaskProgress,
                MaxProgress     = TaskMaximumProgress
            };

            // Pass it to the service to handle it
            mTimeTasksService.SaveTask(newTask);

            // Close this page
            mUIManager.GoBackToPreviousPage(this);

            // Refresh UI list so it gets new task
            TaskListHelpers.RaiseRefreshEvent();
        }
예제 #2
0
 /// <summary>
 /// Maps a <see cref="TimeTaskContext"/> to a <see cref="TimeTask"/> object
 /// </summary>
 /// <param name="context">The <see cref="TimeTaskContext"/> to map</param>
 /// <returns><see cref="TimeTask"/></returns>
 public TimeTask ReverseMap(TimeTaskContext context) => mMapper.Map <TimeTask>(context);