Пример #1
0
        public IActionResult AddPrescription([FromBody] DoctorPrescriptionViewModel prescription)
        {
            var             systemUser = userManager.GetUserAsync(User).Result;
            var             doctor     = context.Doctors.First(d => d.SystemUser.Id == systemUser.Id);
            ResultViewModel result     = null;


            if (ModelState.IsValid && prescription.Medicines.Length > 0)
            {
                result = addPrescription.Execute(prescription, doctor.ID);
            }
            else
            {
                result = new ResultViewModel {
                    Succes = false, Message = "Normy recepty nie zostały spełnione"
                };
            }

            return(Json(result));
        }
Пример #2
0
        public void Should_Not_AddPrescription_No_Meds()
        {
            // given
            var expectedResult            = false;
            var expectedPrescriptionCount = context.MedicalPrescriptions.Count();
            var loggerMock = new Mock <ILogger <AddPrescriptionUseCase> >();
            var useCase    = new AddPrescriptionUseCase(context, loggerMock.Object);
            var doctor     = context.Doctors.First();
            var presc      = new DoctorPrescriptionViewModel
            {
                Patient   = Map <PatientViewModel>(context.Patients.First()),
                Medicines = new MedicineViewModel [] { }
            };
            // when
            var actualResult = useCase.Execute(presc, doctor.ID);

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