コード例 #1
0
        public async Task <ActionResult> AddDiseaseHealthCard(AddDiseaseModel addDiseaseModel)
        {
            List <Guid> existingSympthomGuids = new List <Guid>();
            DiseaseDto  diseaseToCreateDto    = new DiseaseDto {
                Name = addDiseaseModel.Name
            };
            var diseaseGuid = await DiseaseFacade.CreateDiseaseAsync(diseaseToCreateDto);

            var sympthomStrings = addDiseaseModel.Sypthoms.Split(',');

            foreach (var sympthom in sympthomStrings)
            {
                var sympthomsByName = await SympthomFacade.GetSympthomByNameAsync(sympthom);

                if (sympthomsByName.Count() != 0)
                {
                    existingSympthomGuids.Add(sympthomsByName.First().Id);
                }
                else
                {
                    SympthomDto newSympthomDto = new SympthomDto {
                        Name = sympthom
                    };
                    existingSympthomGuids.Add(await SympthomFacade.CreateSympthomAsync(newSympthomDto));
                }
            }
            await MatchDiseaseAndSypthoms(diseaseGuid, existingSympthomGuids);

            string identificationNum = await UpdateHealthCard(new HealthCardUpdateModel { DiseaseId = diseaseGuid });

            return(RedirectToAction("PatientAskForGetInfoDoctor", "Patient", new { identificationNumber = identificationNum }));
        }
コード例 #2
0
        private async Task <Guid> MatchDiseaseAndSypthoms(Guid diseaseGuid, List <Guid> existingSympthomGuids)
        {
            Guid id = Guid.Empty;

            foreach (var guid in existingSympthomGuids)
            {
                DiseaseToSympthomDto diseaseToSympthom = new DiseaseToSympthomDto {
                    DiseaseDto = await DiseaseFacade.GetDiseaseAsync(diseaseGuid), SympthomDto = await SympthomFacade.GetSympthomAsync(guid)
                };
                id = await DiseaseAndSympthomFacade.Create(diseaseToSympthom);
            }
            return(id);
        }