Exemplo n.º 1
0
        public void Get_by_id_returns_pharmacy()
        {
            pharmacyRepository.GetById(Guid.Parse("51d5a046-bc14-4cce-9ab0-222565f50526")).Returns(this.GetFirstPharmacy());

            IdentifiableDTO <PharmacyDTO> pharmacy = pharmacyService.GetById(Guid.Parse("51d5a046-bc14-4cce-9ab0-222565f50526"));

            Assert.True(this.ComparePharmacyAndIdentifierPharmacy(this.GetFirstPharmacy(), pharmacy));
        }
        public void Given_GetById_When_APharmacyIdIsPassed_Then_ShouldReturnThePharmacy()
        {
            //Arrange
            var expected = PharmacyFactory.GetPharmacy();

            pharmacyRepositoryMock.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(expected);

            //Act
            var result = sut.GetById(expected.Id);

            //Assert
            pharmacyRepositoryMock.Verify(x => x.GetById(It.IsAny <Guid>()), Times.Once);
            result.Value.Should().BeEquivalentTo(expected.ToModel());
        }
        public async Task <IActionResult> Get()
        {
            var email = _userManager.GetUserId(HttpContext.User);
            var user  = await _userManager.FindByEmailAsync(email);



            var prescription_models = new List <PrescriptionModel>();

            if (await _userManager.IsInRoleAsync(user, "client"))
            {
                var profile = _profileService.Get().FirstOrDefault(e => e.user_id == user.Id);

                var prescriptions = _prescriptionService.Get().Where(e => e.profile_id == profile.id).Include(e => e.clinician_).Include(e => e.profile_).Include(e => e.mp_prescription_drug);


                foreach (var prescription in prescriptions)
                {
                    var pharmacy = prescription.pharmacy_id.HasValue ? _pharmacyService.GetById(prescription.pharmacy_id.Value) : new mp_pharmacy();
                    prescription_models.Add(new PrescriptionModel(prescription, pharmacy));
                }
            }
            else if (await _userManager.IsInRoleAsync(user, "clinician"))
            {
                var clinician     = _clinicianService.Get().FirstOrDefault(e => e.user_id == user.Id);
                var prescriptions = _prescriptionService.Get().Where(e => e.clinician_id == clinician.id).Include(e => e.profile_).Include(e => e.clinician_).Include(e => e.mp_prescription_drug);

                foreach (var prescription in prescriptions)
                {
                    var pharmacy = prescription.pharmacy_id.HasValue ? _pharmacyService.GetById(prescription.pharmacy_id.Value) : new mp_pharmacy();
                    prescription_models.Add(new PrescriptionModel(prescription, pharmacy));
                }
            }

            return(Ok(prescription_models));
        }
Exemplo n.º 4
0
        public IActionResult GetById(Guid id)
        {
            var result = pharmacyService.GetById(id);

            return(result.AsActionResult(NotFound));
        }