コード例 #1
0
        public async Task <IActionResult> UpdateEnrollee(int enrolleeId, EnrolleeProfileViewModel enrolleeProfile, [FromQuery] bool beenThroughTheWizard)
        {
            var enrollee = await _enrolleeService.GetEnrolleeNoTrackingAsync(enrolleeId);

            if (enrollee == null)
            {
                return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}")));
            }

            if (!User.CanEdit(enrollee))
            {
                return(Forbid());
            }

            // If the enrollee is not in the status of 'Editable', it cannot be updated
            if (!(await _enrolleeService.IsEnrolleeInStatusAsync(enrolleeId, StatusType.Editable)))
            {
                this.ModelState.AddModelError("Enrollee.CurrentStatus", "Enrollee can not be updated when the current status is not 'Editable'.");
                return(BadRequest(ApiResponse.BadRequest(this.ModelState)));
            }

            await _enrolleeService.UpdateEnrolleeAsync(enrolleeId, enrolleeProfile, beenThroughTheWizard);

            return(NoContent());
        }
コード例 #2
0
        public async Task CreateEnrolleeSubmissionAsync(int enrolleeId)
        {
            var enrollee = await _enrolleeService.GetEnrolleeNoTrackingAsync(enrolleeId);

            var agreementDto = _mapper.Map <AgreementEngineDto>(enrollee);

            var enrolleeSubmission = new Submission
            {
                EnrolleeId            = enrollee.Id,
                ProfileSnapshot       = JObject.FromObject(enrollee, _camelCaseSerializer),
                AgreementType         = AgreementEngine.DetermineAgreementType(agreementDto),
                RequestedRemoteAccess = enrollee.EnrolleeRemoteUsers.Any(),
                CreatedDate           = DateTimeOffset.Now
            };

            _context.Submissions.Add(enrolleeSubmission);

            await _context.SaveChangesAsync();
        }