Beispiel #1
0
        public int InsertPlant(PlantAddRequest model)
        {
            int id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Plants_Insert"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Name", model.Name);
                paramCollection.AddWithValue("@Description", model.Description);
                paramCollection.AddWithValue("@CategoryId", model.CategoryId);
                paramCollection.AddWithValue("@SizeId", model.SizeId);
                paramCollection.AddWithValue("@IsBioluminescent", model.IsBioluminescent);

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

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

            return(id);
        }
Beispiel #2
0
        public HttpResponseMessage InsertPlant(PlantAddRequest model)
        {
            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = _plantsService.InsertPlant(model);

            return(Request.CreateResponse(response));
        }