public IActionResult PrescriptionDetails(int prescriptionId) { var user = userManager.GetUserAsync(User).Result; var doctor = context.Doctors.Single(d => d.SystemUser.Id == user.Id); if (doctor == null) { return(NotFound()); } var result = getPrescriptionDetails.Execute(prescriptionId); return(View(result)); }
public IActionResult Prescription(int prescriptionId) { var user = userManager.GetUserAsync(User).Result; var patient = context.Patients.Single(p => p.SystemUser.Id == user.Id); var result = getPrescriptionDetailsUseCase.Execute(patient.ID, prescriptionId); if (result.Succes) { return(View(result.Data)); } return(NotFound()); }
public void Should_Not_Get_Prescription_Details() { // given var patient = context.Patients.First(p => p.SecondName == "One"); var prescription = context.MedicalPrescriptions .First(p => p.VerificationState == VerificationState.Accepted); var expectedResult = false; var loggerMock = new Mock <ILogger <GetPrescriptionDetailsUseCase> >(); var useCase = new GetPrescriptionDetailsUseCase(context, loggerMock.Object); // when var actualResult = useCase.Execute(patient.ID, prescription.ID); // then Assert.AreEqual(expectedResult, actualResult.Succes); }
public void Should_Get_Prescription_Details() { // given var patient = context.Patients.First(p => p.SecondName == "One"); var prescription = context.MedicalPrescriptions .First(p => p.VerificationState == VerificationState.NotVerified); var expectedResult = new ResultViewModel <PrescriptionViewModel> { Data = Map <PrescriptionViewModel>(prescription) }; var loggerMock = new Mock <ILogger <GetPrescriptionDetailsUseCase> >(); var useCase = new GetPrescriptionDetailsUseCase(context, loggerMock.Object); // when var actualResult = useCase.Execute(patient.ID, prescription.ID); // then Assert.AreEqual(expectedResult.Succes, actualResult.Succes); Assert.AreEqual(expectedResult.Data.Id, actualResult.Data.Id); }