コード例 #1
0
        public void TestModelValidationFail()
        {
            var target = new NewPatientRequest();
            var thrown = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m)));

            Assert.AreEqual("Name is required.", thrown.Message);

            target.Name = new FirstLast();
            thrown      = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m)));
            Assert.AreEqual("First name required.", thrown.Message);

            target.Name.First = "First Name";
            thrown            = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m)));
            Assert.AreEqual("Email address required.", thrown.Message);

            target.Email = "*****@*****.**";
            thrown       = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m)));
            Assert.AreEqual("Address required.", thrown.Message);

            target.Address = "I.R. Address";
            thrown         = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m)));
            Assert.AreEqual("Date of birth required.", thrown.Message);


            target.Dob = new DateTime(2015, 1, 1);
            thrown     = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m)));
            Assert.AreEqual("ProviderId required.", thrown.Message);

            target.ProviderId = 1;
            bool actual = target.ValidateModel(m => new Exception(m));

            Assert.IsTrue(actual);
        }
コード例 #2
0
 public IActionResult UpdatePatient(long urlDepId, long patId, [FromBody] NewPatientRequest request)
 {
     return(ValidateTokenAndExecute(urlDepId, (depId) => {
         patService.updatePatient(
             depId, patId, request.firstName, request.lastName, request.details, request.isWIP, request.priority
             );
         return NoContent();
     }));
 }
コード例 #3
0
        public ApiResponseV2 <NewPatientResponse> NewPatient(NewPatientRequest request)
        {
            if (request.ValidateModel())
            {
                const string url    = "v2/patients";
                var          result = Post <ApiResponseV2 <NewPatientResponse> >(url, request);
                return(result);
            }

            throw new SnapSdkException("Model invalid");
        }
コード例 #4
0
 public IActionResult CreatePatient(long urlDepId, [FromBody] NewPatientRequest request)
 {
     return(ValidateTokenAndExecute(urlDepId, (depId) => {
         var patId = patService.createNewPatient(
             depId, request.firstName, request.lastName, request.details, request.isWIP, request.priority
             );
         //Allow client to access the header 'patId' only for this action
         Response.Headers.Add("Access-Control-Expose-Headers", "patId");
         //return patient id in header
         Response.Headers.Add("patId", patId.ToString());
         return StatusCode(201);
     }));
 }