public HttpResponseMessage Post(MilitaryBaseAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }
            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = MilitaryBaseService.Post(model);
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Esempio n. 2
0
        public static int Post(MilitaryBaseAddRequest model)
        {
            int id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.MilitaryBase_Insert",
                                         inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                MapCommonParameters(model, paramCollection);

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

                paramCollection.Add(p);
            }, returnParameters : delegate(SqlParameterCollection param)
            {
                Int32.TryParse(param["@Id"].Value.ToString(), out id);
            }
                                         );

            return(id);
        }
Esempio n. 3
0
 private static void MapCommonParameters(MilitaryBaseAddRequest model, SqlParameterCollection paramCollection)
 {
     paramCollection.AddWithValue("@MilitaryBase", model.MilitaryBaseName);
 }