Esempio n. 1
0
        public async Task <IActionResult> UpdateEntry([FromRoute] Guid organizationId, [FromRoute] Guid entryId,
                                                      [FromBody] TimeEntryInput input)
        {
            var entry = await _timeService.UpdateTimeEntry(_contractor, entryId, input);

            return(Ok(entry));
        }
Esempio n. 2
0
        public async Task <IActionResult> SaveAndApprove(
            [FromRoute] Guid organizationId,
            [FromRoute] Guid entryId,
            [FromBody] TimeEntryInput input
            )
        {
            var result = await _timeEntryService
                         .SaveAndApprove(_agencyOwner, entryId, input);

            return(Ok(result));
        }
        public async Task <TimeEntryResult> UpdateTimeEntry(IOrganizationProjectManager co, Guid entryId, TimeEntryInput input)
        {
            _logger.LogInformation(GetLogMessage("Entry: {0}"), entryId);
            var retVal = new TimeEntryResult()
            {
                TimeEntryId = entryId
            };

            var entry = await Repository.FirstOrDefaultAsync(x => x.Id == entryId);

            if (entry.Status == TimeStatus.Logged)
            {
                if (input.MinutesDuration.HasValue && input.MinutesDuration.Value > 0)
                {
                    input.EndDate = input.StartDate.AddMinutes(input.MinutesDuration.Value);
                }

                entry.InjectFrom(input);

                retVal = await UpdateTimeEntry(entry);
            }
            else
            {
                retVal.ErrorMessage = "You can only update time entry in the logged state";
            }

            return(retVal);
        }
        public async Task <TimeEntryResult> UpdateTimeEntry(IOrganizationContractor co, Guid entryId, TimeEntryInput input)
        {
            _logger.LogInformation(GetLogMessage("Entry: {0}"), entryId);

            var entry = await Repository
                        .FirstOrDefaultAsync(x => x.Id == entryId);

            var retVal = new TimeEntryResult {
                TimeEntryId = entryId
            };

            if (entry.Status == TimeStatus.Logged || entry.Status == TimeStatus.Rejected)
            {
                if (input.MinutesDuration.HasValue && input.MinutesDuration.Value > 0)
                {
                    input.EndDate = input.StartDate.AddMinutes(input.MinutesDuration.Value);
                }

                if (entry.Status == TimeStatus.Rejected)
                {
                    entry.Status = TimeStatus.Logged;
                    entry.StatusTransitions.Add(new TimeEntryStatusTransition()
                    {
                        Status      = TimeStatus.Logged,
                        ObjectState = ObjectState.Added
                    });
                }


                entry.InjectFrom(input);

                entry.ObjectState = ObjectState.Modified;
                entry.Updated     = DateTimeOffset.UtcNow;

                var storyId         = input.StoryId;
                var isStoryComplete = input.CompleteStory;

                if (!input.StoryId.HasValue)
                {
                    return(await UpdateTimeEntry(entry));
                }

                var story = await _storyService.Repository
                            .Queryable()
                            .FirstOrDefaultAsync(x => x.Id == storyId.Value);

                if (isStoryComplete.HasValue && isStoryComplete is true)
                {
                    story.Status = StoryStatus.Completed;
                    story.StatusTransitions.Add(new StoryStatusTransition()
                    {
                        Status = StoryStatus.Completed
                    });
                    //else if (isStoryComplete is false) story.Status = StoryStatus.InProgress;
                }

                story.ObjectState = ObjectState.Modified;
                story.Updated     = DateTimeOffset.UtcNow;

                var result = await _storyService.Repository.UpdateAsync(story, true);

                return(await UpdateTimeEntry(entry));
            }

            return(retVal);
        }
        public async Task <TimeEntryResult> UpdateTimeEntry(IAgencyOwner ao, Guid entryId, TimeEntryInput input)
        {
            _logger.LogInformation(GetLogMessage("Entry: {0}"), entryId);

            var entry = await Repository.FirstOrDefaultAsync(x => x.Id == entryId);

            if (input.MinutesDuration.HasValue && input.MinutesDuration.Value > 0)
            {
                input.EndDate = input.StartDate.AddMinutes(input.MinutesDuration.Value);
            }

            entry.InjectFrom(input);

            return(await UpdateTimeEntry(entry));
        }
        public async Task <TimeEntryResult> SaveAndApprove(IOrganizationProjectManager pm, Guid entryId, TimeEntryInput input)
        {
            var entry = await UpdateTimeEntry(pm, entryId, input);

            var entry2 = await Approve(pm, new[] { entryId });

            return(entry2);
        }
        public async Task <TimeEntryResult> SaveAndApprove(IAgencyOwner ao, Guid entryId, TimeEntryInput input)
        {
            var entry = await UpdateTimeEntry(ao, entryId, input);

            return(await Approve(ao, new[] { entryId }));
        }