public async Task <ResidentDTO> Post([FromBody, Required] ResidentDTO resident)
        {
            List <TestResult> testResultTypes = await TestResultModel.GetTestResultTypes();

            Resident res        = Resident.ConvertFromDTO(resident, testResultTypes);
            int      residentId = await ResidentModel.CreateResidentEntry(res);

            resident.ResidentID = residentId;
            return(resident);
        }
        public async Task <ActionResult> Put([FromRoute, Required] int residentId,
                                             [FromBody, Required] ResidentDTO resident)
        {
            List <TestResult> testResultTypes = await TestResultModel.GetTestResultTypes();

            Resident res = Resident.ConvertFromDTO(resident, testResultTypes);

            await ResidentModel.UpdateResidentEntry(residentId, res);

            return(new OkResult());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="residentDto"></param>
        /// <param name="testResultTypes"></param>
        /// <returns></returns>
        public static Resident ConvertFromDTO(ResidentDTO residentDto, List <TestResult> testResultTypes)
        {
            int        testResultCode = residentDto.Covid19TestResult;
            TestResult testResult     = new TestResult(
                testResultCode,
                testResultTypes.Find(it =>
                                     it.TestResultType == testResultCode).TestResultDescription);

            return(new Resident(
                       residentDto.ResidentID,
                       residentDto.FirstName,
                       residentDto.LastName,
                       residentDto.PGY,
                       residentDto.PhoneNumber,
                       residentDto.SymptomsDate,
                       residentDto.SymptomsDescription,
                       residentDto.Covid19TestDate,
                       testResult,
                       residentDto.IsQuarantined,
                       residentDto.QuarantinedUntil
                       ));
        }
Esempio n. 4
0
 public async Task UpdateResident(ResidentDTO dto)
 {
     var resident = _mapper.Map <Resident>(dto);
     await _repo.UpdateResident(resident);
 }