public async Task <IActionResult> Edit(Dictionary <string, string> d)
        {
            var personMed = await personMedicines.GetObject(d["medId"], d["perId"]);

            var dosage = await dosages.GetObject(d["dosId"]);

            var medicine = await medicines.GetObject(d["medId"]);

            return(View(PersonInfoViewModelFactory.Create(dosage, personMed, medicine)));
        }
        public async Task <IActionResult> PatientInfo(PersonViewModel model)
        {
            var idCode = model.IDCode;

            try
            {
                PersonObject persona;
                if (model.ID != Constants.Unspecified)
                {
                    persona = await persons.GetObject(model.ID);
                }
                else
                {
                    persona = await persons.GetPersonByIDCode(idCode);
                }


                await personMedicines.LoadMedicines(persona);

                var personView        = PersonViewModelFactory.Create(persona);
                var personSuggestions = await dosages.GetAllDosages(persona.DbRecord.ID);

                foreach (var sug in personSuggestions)
                {
                    var pm = await personMedicines.GetObject(sug.DbRecord.MedicineID, persona.DbRecord.ID);

                    var med = await medicines.GetObject(sug.DbRecord.MedicineID);

                    personView.SuggestionsMade.Add(PersonInfoViewModelFactory.Create(sug, pm, med));
                }
                return(View("PatientInfo", personView));
            }
            catch (Exception e)
            {
                ViewBag.Message = "Sellise id-koodiga inimene puudub!";
                return(View("Index"));
            }
        }