public async Task <ActionResult <UserGrantMapping> > GrantDetails(UserGrantMappingDto mappingDto) { //If the user doesn't add grant details if (mappingDto.GrantId == 0 || mappingDto.UserId == 0) { return(NoContent()); } if (await _applicant.DidApplicantAlreadyApply(mappingDto)) { return(BadRequest("You have already applied for this grant!")); } //saves to usergrant mapping table return(await _applicant.GrantDetails(mappingDto)); }
public async Task <UserGrantMapping> GrantDetails(UserGrantMappingDto mappingDto) { string applicationStatus; if (await _education.EducationDetailsExistsForApplicant(mappingDto.UserId)) { applicationStatus = "Completed"; } else { applicationStatus = "Submitted"; } var mappingDetails = new UserGrantMapping { UserId = mappingDto.UserId, GrantId = mappingDto.GrantId, ApplicationStatus = applicationStatus }; return(await _applicant.SaveGrantDetails(mappingDetails)); }
public async Task <bool> DidApplicantAlreadyApply(UserGrantMappingDto mappingDto) { return(await _context.UserGrantMappings.AnyAsync(x => x.UserId == mappingDto.UserId && x.GrantId == mappingDto.GrantId)); }
public async Task <bool> DidApplicantAlreadyApply(UserGrantMappingDto mappingDto) { return(await _applicant.DidApplicantAlreadyApply(mappingDto)); }