Beispiel #1
0
        public async Task <ActionResult <AdjudicatorNote> > CreateAdjudicatorNote(int enrolleeId, FromBodyText note, [FromQuery] bool link)
        {
            if (!await _enrolleeService.EnrolleeExistsAsync(enrolleeId))
            {
                return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}")));
            }

            if (string.IsNullOrWhiteSpace(note))
            {
                this.ModelState.AddModelError("note", "Adjudicator notes can't be null or empty.");
                return(BadRequest(ApiResponse.BadRequest(this.ModelState)));
            }

            var admin = await _adminService.GetAdminForUserIdAsync(User.GetPrimeUserId());

            var createdAdjudicatorNote = await _enrolleeService.CreateEnrolleeAdjudicatorNoteAsync(enrolleeId, note, admin.Id);

            if (link)
            {
                // Link Adjudicator note to most recent status change on an enrollee if request
                var enrollee = await _enrolleeService.GetEnrolleeAsync(enrolleeId);

                await _enrolleeService.AddAdjudicatorNoteToReferenceIdAsync(enrollee.CurrentStatus.Id, createdAdjudicatorNote.Id);
            }

            return(CreatedAtAction(
                       nameof(CreateAdjudicatorNote),
                       new { enrolleeId = enrolleeId },
                       ApiResponse.Result(createdAdjudicatorNote)
                       ));
        }
        public async Task <ActionResult <EnrolleeViewModel> > AssignToaAgreementType(int enrolleeId, [FromBody] AgreementType agreementType)
        {
            if (!await _enrolleeService.EnrolleeExistsAsync(enrolleeId))
            {
                return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}")));
            }

            var assignedToaType = (agreementType == 0) ? null : (AgreementType?)agreementType;

            if (assignedToaType.HasValue && !Enum.IsDefined(typeof(AgreementType), agreementType))
            {
                return(NotFound(ApiResponse.Message($"Agreement type not found with id {agreementType}.")));
            }

            if (assignedToaType.HasValue && !agreementType.IsEnrolleeAgreement())
            {
                this.ModelState.AddModelError("AgreementType", "Agreement type must be a TOA.");
                return(BadRequest(ApiResponse.BadRequest(this.ModelState)));
            }

            if (!await _enrolleeService.IsEnrolleeInStatusAsync(enrolleeId, StatusType.UnderReview))
            {
                this.ModelState.AddModelError("Enrollee.CurrentStatus", "Assigned agreement type can not be updated when the current status is not 'Under Review'.");
                return(BadRequest(ApiResponse.BadRequest(this.ModelState)));
            }

            await _enrolleeService.AssignToaAgreementType(enrolleeId, assignedToaType);

            await _businessEventService.CreateAdminActionEventAsync(enrolleeId, "Admin assigned agreement");

            var updatedEnrollee = await _enrolleeService.GetEnrolleeAsync(enrolleeId);

            return(Ok(ApiResponse.Result(updatedEnrollee)));
        }
Beispiel #3
0
        private async Task <ActionResult> ManualFlagInternal(int enrolleeId, bool alwaysManual)
        {
            var enrolleeExists = await _enrolleeService.EnrolleeExistsAsync(enrolleeId);

            if (!enrolleeExists)
            {
                return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}.")));
            }

            // TODO business event
            await _submissionService.UpdateAlwaysManualAsync(enrolleeId, alwaysManual);

            return(NoContent());
        }