コード例 #1
0
        /// <summary>
        /// Maps properties from TaskBLL to TaskVM. 
        /// Does not set ParentGroup property.
        /// </summary>
        public static TaskVM TaskBllToTaskVm(TaskBLL bllTask)
        {
            TaskInfo ti = new TaskInfo(bllTask.Title, bllTask.BackgroundColor, bllTask.FontColor,
                                       bllTask.FontName, bllTask.FontSize, bllTask.BeginTime, bllTask.Details);

            return new TaskVM(bllTask.ItemID, ti,  bllTask.Status, bllTask.ResolveTime);
        }
コード例 #2
0
        public TaskBLL(int id, int? parentGroupId, TaskInfo tInfo, TaskStatuses status,
            DateTime? resolveTime, TimedTaskSettingsInfo timingInfo)
            : base(id, parentGroupId, tInfo, resolveTime)
        {
            Status = status;
            Details = tInfo.Details;

            if (timingInfo != null)
            {
                TimingInfo = new TimedTaskSettingsInfo();
                TimingInfo.DueTime = timingInfo.DueTime;
                TimingInfo.TimeoutAction = timingInfo.TimeoutAction;
            }
        }
コード例 #3
0
ファイル: TaskVM.cs プロジェクト: ManiacalAce/ProcrastinHater
 public TaskVM(int id, TaskInfo taskInfo, TaskStatuses status, DateTime? resolveTime, GroupVM parentGroup = null)
     : base(id, taskInfo, resolveTime, parentGroup)
 {
     Details = taskInfo.Details;
     Status = status;
 }
コード例 #4
0
        public bool AddNewTask(TaskInfo taskInfo, int? parentGroupId,
            TimedTaskSettingsInfo timingInfo, out string errors)
        {
            errors = "";

            if (taskInfo == null)
            {
                errors = "The provided TaskInfo object is null.";
                return false;
            }

            Task taskToAdd = new Task();
            TaskInfoToTask(taskInfo, taskToAdd);
            taskToAdd.StatusID = 100;
            taskToAdd.ParentGroupID = parentGroupId;

            bool taskIsValid = true;
            bool timingInfoIsValid = true;

            string taskValidationErrs = "";
            taskIsValid = ValidateTask(taskToAdd, out taskValidationErrs);

            TimedTaskSettings newTTS = null;

            string ttsValidationErrs = "";
            if (timingInfo != null)
            {
                newTTS = new TimedTaskSettings();
                TTSInfoToTTS(timingInfo, newTTS);

                timingInfoIsValid = ValidateTimedTaskSettings(newTTS, out ttsValidationErrs);
            }

            if (!taskIsValid || !timingInfoIsValid)
                errors += taskValidationErrs + ttsValidationErrs;
            else
            {

                int newTaskKey = HardSettingsManager.GetAndAdvanceNextChecklistElementKey(_context);

                if (newTaskKey != -1)
                {
                    if (newTTS != null)
                    {
                        //sigh.. validate this too?
                        newTTS.TimedTaskSettingsID = HardSettingsManager.GetAndAdvanceNextTimedTaskSettingsKey(_context);

                        taskToAdd.TimedTaskSettings = newTTS;
                    }

                    taskToAdd.ItemID = newTaskKey;
                    BLLUtility.AddPositionInfo(_context, taskToAdd, parentGroupId);

                    _context.ChecklistElements.AddObject(taskToAdd);
                    _context.SaveChanges();

                    return true;
                }
                else
                    errors += "The next-key information could not be retreived from the database.\n";
            }

            return false;
        }
コード例 #5
0
 public bool AddNewTask(TaskInfo taskInfo, int? parentGroupId, 
     out string errors)
 {
     return AddNewTask(taskInfo, parentGroupId, null, out errors);
 }
コード例 #6
0
        private void TaskInfoToTask(TaskInfo ti, Task t)
        {
            BLLUtility.ChecklistElementInfoToChecklistElement(ti, t);

            t.Details = ti.Details;
        }
コード例 #7
0
        /// <summary>
        /// Update task's information. For changing task's 'Status', use ChangeStatus().
        /// </summary>
        public bool UpdateTaskDescriptors(int id, TaskInfo taskInfo, out string errors)
        {
            /*
                If task did not have 'PositionInformation' and new 'BeginTime'
                is within position-tracked days, add a PosInfo to it.
                Pos = end of parent group (take care of top lvl task, parent == null).

                Besides that, just update properties.
            */
            //TODO: Ponder about the need to allow changes on ResolveTime (via another method...  not this one)

            errors = "";

            Task taskToUpdate = _context.ChecklistElements.OfType<Task>()
                .SingleOrDefault(t => t.ItemID == id);

            if (taskToUpdate != null)
            {
                HardSettings settings = _context.HardSettingsSet.SingleOrDefault(hs => hs.Check == true);

                if (settings != null)
                {
                    TaskInfoToTask(taskInfo, taskToUpdate);

                    if (ValidateTask(taskToUpdate, out errors))
                    {
                        CheckIfNewBeginTimeAffectsPosInfo(taskToUpdate, settings);

                        _context.SaveChanges();
                        return true;
                    }
                    else
                        return false;

                }
                else
                {
                    errors = "The database is corrupt. Settings info could not be retreived.";
                    return false;
                }
            }
            else
            {
                errors = "No Task with the specified ItemID exists.";
                return false;
            }
        }