public IActionResult SubmitDiagnosis(ODataActionParameters parameter)
        {
            string ID = parameter["ID"].ToString();

            if (ID.Length > 0)
            {
                Person p = repo.Read(ID);

                if (p != null)
                {
                    // 1. Record current time
                    DateTime timeStampNow = DateTime.Now;

                    // 2. Instantiate new Diagnosis
                    InfectiousDisease d = new InfectiousDisease($"COVID19_{timeStampNow.ToString("HHmmssddMMyyyy")}");
                    d.Classification = "COVID-19";
                    d.DateDiagnosed  = timeStampNow;

                    // 3. Bind the newly created individual to the database
                    d.SetModel(p.Model);
                    d.Commit();

                    // 4. Associate the newly created individual to the desired person
                    p.Diagnosis.Add(d);
                    repo.Update(p);

                    return(Ok(d));
                }
            }

            return(BadRequest());
        }
Ejemplo n.º 2
0
        public IActionResult Get([FromODataUri] string key)
        {
            InfectiousDisease Obj = repo.Read(key);

            return((Obj is null) ? (IActionResult)NotFound() : Ok(Obj));
        }