Example #1
0
        public IActionResult DeletePrescription(int prescriptionId)
        {
            var user   = userManager.GetUserAsync(User).Result;
            var doctor = context.Doctors
                         .First(d => d.SystemUser.Id == user.Id);

            var result = deletePrescription.Execute(doctor.ID, prescriptionId);

            return(result.Succes ?
                   RedirectToAction("Prescriptions") :
                   (IActionResult)NotFound());
        }
Example #2
0
        public void Should_Delete_Prescription()
        {
            // given
            var expectedResult            = true;
            var expectedPrescriptionCount = context.MedicalPrescriptions.Count() - 1;
            var loggerMock = new Mock <ILogger <DeletePrescriptionUseCase> >();
            var useCase    = new DeletePrescriptionUseCase(context, loggerMock.Object);
            var doctor     = context.Doctors.First();
            var presc      = context.MedicalPrescriptions.First();

            // when
            var actualResult = useCase.Execute(presc.Doctor.ID, presc.ID);

            // then
            Assert.AreEqual(expectedResult, actualResult.Succes);
            Assert.AreEqual(expectedPrescriptionCount, context.MedicalPrescriptions.Count());
        }
Example #3
0
        public void Should_Not_Delete_Prescription()
        {
            // given
            var expectedResult            = false;
            var expectedPrescriptionCount = context.MedicalPrescriptions.Count();
            var loggerMock = new Mock <ILogger <DeletePrescriptionUseCase> >();
            var useCase    = new DeletePrescriptionUseCase(context, loggerMock.Object);
            var doctor     = context.Doctors.First();
            var presc      = context.MedicalPrescriptions.First();
            var uselessDoc = new Doctor {
                FirstName = "Useless", SecondName = "Doc"
            };

            context.Doctors.Add(uselessDoc);
            context.SaveChanges();

            // when
            var actualResult = useCase.Execute(uselessDoc.ID, presc.ID);

            // then
            Assert.AreEqual(expectedResult, actualResult.Succes);
            Assert.AreEqual(expectedPrescriptionCount, context.MedicalPrescriptions.Count());
        }