public async Task <IssueTimeSheetDTO> CreateAsync(ObjectId issueId, IssueTimeSheetDTO timeSheetDto)
        {
            ThrowErrorIfEndIsBeforStart(timeSheetDto);
            var issue = await _issueRepo.GetAsync(issueId);

            var user   = _httpContextAccessor.HttpContext.User;
            var userId = user.GetUserId();

            if ((await _authorizationService.AuthorizeAsync(user, issue, IssueOperationRequirments.CreateOwnTimeSheets)).Succeeded is false)
            {
                throw new HttpStatusException(StatusCodes.Status403Forbidden, "You are not allowed to create a time sheet.");
            }
            var timesheet = timeSheetDto.ToTimeSheet();

            timesheet.Id     = ObjectId.GenerateNewId();
            timesheet.UserId = userId;
            issue.TimeSheets.Add(timesheet);
            issue.IssueDetail.TotalWorkTime = CalculateWorkedTime(issue);

            await StopAllTimeSheetsOfUserAsync(userId);

            await _issueRepo.UpdateAsync(issue);

            await CreateTimeExccededMessage(issueId, timeSheetDto);

            return(await GetAsync(issueId, timesheet.Id));
        }
        public async Task UpdateAsync(ObjectId issueId, ObjectId id, IssueTimeSheetDTO timeSheetDto)
        {
            ThrowErrorIfEndIsBeforStart(timeSheetDto);
            var issue = await _issueRepo.GetAsync(issueId);

            // updating own timesheets require other requirements.
            if (_httpContextAccessor.HttpContext.User.GetUserId().Equals(timeSheetDto.User.Id))
            {
                await CanUserUpdateOwnTimeSheetAsync(issue);
            }
            else
            {
                await CanUserUpdateTimeSheetAsync(issue);

                // Send Message to User
                await CreateTimeChangedMessage(issue, timeSheetDto);
            }


            issue.TimeSheets.Replace(it => it.Id == timeSheetDto.Id, timeSheetDto.ToTimeSheet());
            issue.IssueDetail.TotalWorkTime = CalculateWorkedTime(issue);
            await _issueRepo.UpdateAsync(issue);

            await CreateTimeExccededMessage(issueId, timeSheetDto);
        }