示例#1
0
        public IActionResult Index(int ProjectList, int plannedTasksList, string starttime, int duration = 0, int workid = 0)
        {
            TimeSpan ts            = TimeSpan.Parse(starttime);
            DateTime startDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, ts.Hours, ts.Minutes, 0);

            if (duration == 0)
            {
                TimeSpan timedifference = DateTime.Now - startDateTime;
                duration = (int)timedifference.TotalMinutes;
            }

            if (workid > 0)
            {
                var tasksDoingEntity = _context.TasksDoing.Find(workid);
                tasksDoingEntity.duration = duration;
            }
            else
            {
                var tasksDoingEntity = new TasksDoing()
                {
                    planid = plannedTasksList, starttime = startDateTime, duration = duration
                };
                _context.TasksDoing.Add(tasksDoingEntity);
            }
            _context.SaveChanges();

            return(RedirectToAction("Index", new { planid = plannedTasksList }));
        }
示例#2
0
        public string Start(int planid)
        {
            var workEntity = new TasksDoing()
            {
                planid = planid, starttime = DateTime.Now
            };

            _context.TasksDoing.Add(workEntity);
            _context.SaveChanges();

            return(workEntity.workid.ToString());
        }