Exemplo n.º 1
0
        public static string RegisterPause(string eachTaskId)
        {
            string msg = null;

            switch (CheckTaskStatus(eachTaskId))
            {
            case TaskStatus.AlreadyPaused:
                msg = GetLangMessage.GetMessage("Msg1017");
                break;

            case TaskStatus.AlreadyFinished:
                msg = GetLangMessage.GetMessage("Msg1018");
                break;

            case TaskStatus.NoProblem:
                using (var db = new MemoAppContext())
                {
                    TimeInfo stopTimeInfo = db.TimeInfos.Where(timeInfo => timeInfo.EachTask.EachTaskId == eachTaskId && timeInfo.Stop == DateTimeOffset.MinValue).FirstOrDefault();
                    stopTimeInfo.Stop = DateTimeOffset.Now.ToLocalTime();

                    db.SaveChanges();
                }
                break;

            case TaskStatus.NotYetStarted:
                msg = GetLangMessage.GetMessage("Msg1019");
                break;
            }
            return(msg);
        }
Exemplo n.º 2
0
        public static void Register(string eachTaskId, string memoContent)
        {
            using (var db = new MemoAppContext())
            {
                EachTask targetTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == eachTaskId).FirstOrDefault();

                if (targetTask == null)
                {
                    return;
                }

                Memo sameMemo = db.Memos.Where(memo => memo.EachTask.EachTaskId == eachTaskId).FirstOrDefault();

                if (sameMemo == null)
                {
                    Memo newMemo = new Memo
                    {
                        CreateTime = DateTimeOffset.Now.ToLocalTime(),
                        Content    = memoContent,
                        EachTask   = targetTask
                    };

                    db.Memos.Add(newMemo);
                }
                else
                {
                    sameMemo.Content    = memoContent;
                    sameMemo.UpdateTime = DateTimeOffset.Now.ToLocalTime();
                }

                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public static string RegisterPause(string eachTaskId)
        {
            string msg = null;

            switch (CheckTaskStatus(eachTaskId))
            {
            case TaskStatus.AlreadyPaused:
                msg = "すでに一時停止中です。";
                break;

            case TaskStatus.AlreadyFinished:
                msg = "すでに完了済みのタスクです。";
                break;

            case TaskStatus.NoProblem:
                using (var db = new MemoAppContext())
                {
                    TimeInfo stopTimeInfo = db.TimeInfos.Where(timeInfo => timeInfo.EachTask.EachTaskId == eachTaskId && timeInfo.Stop == DateTimeOffset.MinValue).FirstOrDefault();
                    stopTimeInfo.Stop = DateTimeOffset.Now.ToLocalTime();

                    db.SaveChanges();
                }
                break;

            case TaskStatus.NotYetStarted:
                msg = "このタスクはまだ開始されていません。";
                break;
            }
            return(msg);
        }
Exemplo n.º 4
0
 public static string RegisterTask(EachTask newTask)
 {
     using (var db = new MemoAppContext())
     {
         db.EachTasks.Add(newTask);
         db.SaveChanges();
         return(GetEachTaskId(newTask));
     }
 }
Exemplo n.º 5
0
 public static void ChangeValidFlag(string targetTaskId, bool flagValue)
 {
     using (var db = new MemoAppContext())
     {
         EachTask targetTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == targetTaskId).FirstOrDefault();
         targetTask.ValidFlag = flagValue;
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
        public static string RegisterStart(string eachTaskId)
        {
            string msg = null;

            using (var db = new MemoAppContext())
            {
                var selectedTask = db.EachTasks.FirstOrDefault(eachTask => eachTask.EachTaskId == eachTaskId);

                List <TimeInfo> notStoppedInfo  = db.TimeInfos.Where(timeInfo => timeInfo.Stop == DateTimeOffset.MinValue).Include(timeInfo => timeInfo.EachTask).ToList();
                TimeInfo        doubleStartTask = notStoppedInfo.Where(timeInfo => timeInfo.EachTask.EachTaskId == eachTaskId).FirstOrDefault();

                if (doubleStartTask != null)
                {
                    msg = GetLangMessage.GetMessage("Msg1015");
                }
                else
                {
                    if (selectedTask.CompleteFlag == true)
                    {
                        EachTask completeTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == eachTaskId).FirstOrDefault();
                        completeTask.CompleteFlag = false;

                        msg = GetLangMessage.GetMessage("Msg1016");
                    }
                    else
                    {
                        TimeInfo startTimeInfo = new TimeInfo()
                        {
                            Start    = DateTimeOffset.Now.ToLocalTime(),
                            EachTask = db.EachTasks.FirstOrDefault(eachTask => eachTask.EachTaskId == eachTaskId)
                        };
                        db.TimeInfos.Add(startTimeInfo);

                        selectedTask.StartedFlag = true;
                    }

                    notStoppedInfo.ForEach(timeInfo => timeInfo.Stop = DateTimeOffset.Now.ToLocalTime());

                    db.SaveChanges();
                }
            }

            return(msg);
        }