Exemplo n.º 1
0
        private async Task <string> UpdateHealthCard(HealthCardUpdateModel healthCardUpdateModel)
        {
            var identificationNum = Request.QueryString["identificationNumber"];
            var patientToUpdate   = await PatientFacade.GetPatientByIdentificationNumberAsync(identificationNum);

            var healthCard = await HealthCardFacade.GetHealthCardAsync(patientToUpdate.Id);

            if (healthCard == null)
            {
                var healthCardDto = new HealthCardDto {
                    Id = patientToUpdate.Id, LastUpdate = DateTime.Now
                };
                await HealthCardFacade.CreateHealthCardAsync(healthCardDto);

                healthCard = await HealthCardFacade.GetHealthCardAsync(patientToUpdate.Id);
            }

            if (healthCardUpdateModel.BloodType != HospitalISDBContext.Enums.BloodType.Unknown)
            {
                healthCard.BloodType = healthCardUpdateModel.BloodType;
            }

            if (healthCardUpdateModel.DiseaseId != Guid.Empty)
            {
                await MatchDiseaseAndHealthCard(await DiseaseFacade.GetDiseaseAsync(healthCardUpdateModel.DiseaseId), healthCard);
            }

            healthCard.LastUpdate = DateTime.Now;
            await HealthCardFacade.EditHealthCardAsync(healthCard);

            return(identificationNum);
        }
Exemplo n.º 2
0
        private async Task <Guid> MatchDiseaseAndHealthCard(DiseaseDto diseaseDto, HealthCardDto healthCard)
        {
            var diseaseToHealthCard = new DiseaseToHealthCardDto {
                DiseaseDto = diseaseDto, HealthCardDto = healthCard
            };

            return(await DiseaseToHealthCardFacade.Create(diseaseToHealthCard));
        }
Exemplo n.º 3
0
        public async Task <Guid> CreateHealthCardAsync(HealthCardDto healthCard)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                var healthCardId = healthCardService.Create(healthCard);
                await uow.Commit();

                return(healthCardId);
            }
        }
Exemplo n.º 4
0
        public async Task <bool> EditHealthCardAsync(HealthCardDto healthCard)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                if ((await healthCardService.GetAsync(healthCard.Id, true)) == null)
                {
                    return(false);
                }
                await healthCardService.Update(healthCard);

                await uow.Commit();

                return(true);
            }
        }