public async Task <IActionResult> Edit(int id, [Bind("DiseaseSymptomId,DiseaseId,SymptomId")] DiseaseSymptom diseaseSymptom)
        {
            if (id != diseaseSymptom.DiseaseSymptomId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(diseaseSymptom);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DiseaseSymptomExists(diseaseSymptom.DiseaseSymptomId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DiseaseId"] = new SelectList(_context.Diseases, "DiseaseId", "DiseaseName", diseaseSymptom.DiseaseId);
            ViewData["SymptomId"] = new SelectList(_context.Symptoms, "SymptomId", "SymptomName", diseaseSymptom.SymptomId);
            return(View(diseaseSymptom));
        }
Example #2
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            DialogResultEntity = new DiseaseSymptom
            {
                DiseaseId = SelectedDiseaseId,
                SymptomId = SelectedSymptomId
            };

            DialogResult = DialogResult.OK;
        }
        public async Task CreateDiseaseSymptomAsync(int diseaseId, int symptomId)
        {
            var diseaseSymptom = new DiseaseSymptom
            {
                DiseaseId = diseaseId,
                SymptomId = symptomId,
            };

            await this.diseaseSymptomRepository.AddAsync(diseaseSymptom);

            await this.diseaseSymptomRepository.SaveChangesAsync();
        }
Example #4
0
        public DiseaseSymptomCondition(IDisease disease, DiseaseSymptom symptom)
        {
            if (disease is null)
            {
                throw new ArgumentNullException(nameof(disease));
            }

            Symptom = symptom ?? throw new ArgumentNullException(nameof(symptom));

            _diseases = new List<IDisease>();

            HoldDisease(disease);
        }
        public async Task <IActionResult> Create([Bind("DiseaseSymptomId,DiseaseId,SymptomId")] DiseaseSymptom diseaseSymptom)
        {
            if (ModelState.IsValid)
            {
                _context.Add(diseaseSymptom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DiseaseId"] = new SelectList(_context.Diseases, "DiseaseId", "DiseaseName", diseaseSymptom.DiseaseId);
            ViewData["SymptomId"] = new SelectList(_context.Symptoms, "SymptomId", "SymptomName", diseaseSymptom.SymptomId);
            return(View(diseaseSymptom));
        }
        public async Task <DiseaseSymptom> CreateRelationAsync(int diseaseId, int symptomId)
        {
            var createModel = new DiseaseSymptom
            {
                DiseaseId = diseaseId,
                SymptomId = symptomId
            };

            var relationEntry = await _context.DiseasesSymptoms.AddAsync(createModel);

            await _context.SaveChangesAsync();

            return(relationEntry.Entity);
        }
Example #7
0
        private static void AddDiseaseEffectForSymptom(
            IConditionsModule сonditionModule,
            IDisease disease,
            DiseaseSymptom symptom)
        {
            var currentSymptomEffect = сonditionModule.Items.OfType <DiseaseSymptomCondition>()
                                       .SingleOrDefault(x => x.Symptom == symptom);

            if (currentSymptomEffect is null)
            {
                // При создании эффекта уже фиксируется болезнь, которая его удерживает.
                currentSymptomEffect = new DiseaseSymptomCondition(disease, symptom);
                сonditionModule.Add(currentSymptomEffect);
            }
            else
            {
                currentSymptomEffect.HoldDisease(disease);
            }
        }
Example #8
0
        private static void RemoveDiseaseEffectForSimptom(
            IConditionsModule сonditionModule,
            IDisease disease,
            DiseaseSymptom symptom)
        {
            var currentSymptomEffect = сonditionModule.Items.OfType <DiseaseSymptomCondition>()
                                       .SingleOrDefault(x => x.Symptom == symptom);

            if (currentSymptomEffect is null)
            {
                // Просто игнорируем этот эффект.
                // Ткущий метод может вызываться несколько раз и для симптомов, которые ушли в предыдущих итерациях.
                return;
            }

            currentSymptomEffect.ReleaseDisease(disease);

            if (!currentSymptomEffect.Diseases.Any())
            {
                сonditionModule.Remove(currentSymptomEffect);
            }
        }