コード例 #1
0
        public IHttpActionResult PatientAdmin_NewPatient([FromBody] RedoxApi.Models.Patientadmin.Newpatient.Newpatient patient)
        {
            // Make sure this request comes from Redox
            if (!IsAuthorized())
            {
                return(BadRequest());
            }

            // Save the new patient
            try
            {
                PatientService.SaveRedoxPatient(patient);
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return(BadRequest("Validation failed"));
            }
            return(Ok());
        }
コード例 #2
0
ファイル: RedoxApi.cs プロジェクト: CNHume/.NET-Sample-App
        public IRestResponse <NewPatient> NewPatient(NewPatient patient)
        {
            patient.Meta = new Models.Patientadmin.Newpatient.Meta
            {
                DataModel     = "PatientAdmin",
                EventType     = "NewPatient",
                EventDateTime = DateTime.UtcNow.ToString("s", System.Globalization.CultureInfo.InvariantCulture),
            };

            return(Post(patient));
        }