// GET: Diseases/Create
        public async Task <ActionResult> Create()
        {
            var vm = new DiseaseCreateEditViewModel
            {
                SymtomsSelectList = new MultiSelectList(await _symptomService.GetAllAsync(), nameof(Symptom.SymptomId), nameof(Symptom.SymptomName))
            };

            return(View(vm));
        }
        public async Task <ActionResult> Edit(int id, DiseaseCreateEditViewModel vm)
        {
            if (ModelState.IsValid)
            {
                if (vm.SymptomIds != null)
                {
                    vm.Disease.Symptoms = vm.SymptomIds.Select(x => new Symptom()
                    {
                        SymptomId = x
                    }).ToList();
                }
                await _diseaseService.UpdateAsync(vm.Disease);

                return(RedirectToAction(nameof(Index)));
            }
            vm.SymtomsSelectList = new MultiSelectList(await _symptomService.GetAllAsync(),
                                                       nameof(Symptom.SymptomId), nameof(Symptom.SymptomName), vm.SymptomIds);
            return(View(vm));
        }
        // GET: Diseases/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            var disease = await _diseaseService.GetByIdAsync(id);

            if (disease == null)
            {
                return(NotFound());
            }

            var vm = new DiseaseCreateEditViewModel
            {
                SymptomIds = disease.Symptoms.Select(s => s.SymptomId).ToList(),
                Disease    = disease
            };

            vm.SymtomsSelectList = new MultiSelectList(await _symptomService.GetAllAsync(),
                                                       nameof(Symptom.SymptomId), nameof(Symptom.SymptomName), vm.SymptomIds);

            return(View(vm));
        }