Ejemplo n.º 1
0
        private async Task <UserTaskTime> RecordUserTaskTime(bool isStartTimer)
        {
            UserTaskTime usertaskTime = null;

            if (UserTaskTimeList != null)
            {
                usertaskTime = UserTaskTimeList.FirstOrDefault(userTasktime => userTasktime.EndTime == DateTime.MinValue);
            }
            if (usertaskTime == null)
            {
                usertaskTime            = new UserTaskTime();
                usertaskTime.UserTaskID = UserTask.UserTaskID;
            }
            if (isStartTimer)
            {
                usertaskTime.StartTime = DateTime.Now;
                usertaskTime           = await _userTaskService.CreateUserTaskTime(usertaskTime);

                UserTaskTimeList.Add(usertaskTime);
            }
            else
            {
                usertaskTime.EndTime = DateTime.Now;
                await _userTaskService.UpdateUserTaskTime(usertaskTime);
            }

            return(usertaskTime);
        }