Exemple #1
0
        public static Guid InsertTest(TestPersonAddRequest model)
        {
            Guid uid = Guid.Empty;    //000-0000-0000-0000

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.TestTable_Insert"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@FirstName", model.Name);
                paramCollection.AddWithValue("@Last", model.Last);
                paramCollection.AddWithValue("@Age", model.Age);
                paramCollection.AddWithValue("@Email", model.Email);


                SqlParameter p = new SqlParameter("@Uid", System.Data.SqlDbType.UniqueIdentifier);
                p.Direction    = System.Data.ParameterDirection.Output;

                paramCollection.Add(p);
            }, returnParameters : delegate(SqlParameterCollection param)
            {
                Guid.TryParse(param["@Uid"].Value.ToString(), out uid);
            }
                                         );


            return(uid);
        }
Exemple #2
0
        public HttpResponseMessage EchoPerson(TestPersonAddRequest model)
        {
            /*
             * There is no datavalidation in this method. this is simply here for you
             * to be able to echo data back to yourself with no validation
             *
             */

            return(Request.CreateResponse(model));
        }
Exemple #3
0
        public HttpResponseMessage EchoPersonValidation(TestPersonAddRequest model)
        {
            // if the Model does not pass validation, there will be an Error response returned with errors
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            return(Request.CreateResponse(model));
        }
Exemple #4
0
        public HttpResponseMessage AddPerson(TestPersonAddRequest model)
        {
            // if the Model does not pass validation, there will be an Error response returned with errors
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }


            ItemResponse <Guid> response = new ItemResponse <Guid>();

            response.Item = TestService.InsertTest(model);

            return(Request.CreateResponse(response));
        }