예제 #1
0
        public async Task <object> ReOpen(int id, SubmissionReOpenAuditEntryDto model)
        {
            if (model == null)
            {
                return(BadRequest("No audit entry found in request"));
            }

            //TODO: Pulling too much data here
            var submission = await _context.Submissions
                             .Include(r => r.Reports)
                             .Include(f => f.FileSpecification.GenerationGroup)
                             .FirstOrDefaultAsync(x => x.Id == id);

            if (submission == null)
            {
                return(NotFound());
            }

            if (submission.FileSpecification.GenerationGroup == null)
            {
                return(BadRequest($"No generation group defined for File { submission.FileSpecification.FileNumber }"));
            }

            var group = _context.Groups.Include(x => x.Users)
                        .FirstOrDefault(x => x.Id == submission.FileSpecification.GenerationGroupId);

            var assignedUser = _membershipService.GetAssignee(group);

            if (assignedUser == null)
            {
                return(BadRequest($"No group members to assign next task. "));
            }

            var workItem = submission.Reopen(_currentUserFullName, model.Message, assignedUser, model.NextSubmissionDate);

            _context.SaveChanges();

            //TODO: Refactor. Do not have access to new report until after save
            submission.CurrentReportId = submission.Reports.LastOrDefault().Id;

            _context.SaveChanges();

            WorkEmailer.Send(workItem, submission);

            var dto = Mapper.Map <SubmissionViewDto>(submission);

            return(Ok(dto));
        }
예제 #2
0
        public ActionResult ReOpen(int id)
        {
            var audit = new SubmissionReOpenAuditEntryDto(id);

            return(PartialView("_SubmissionReOpenAuditEntry", audit));
        }