public HttpResponseMessage InsertPlanType(PlanTypeAddRequest model) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } ItemResponse<int> response = new ItemResponse<int>(); response.Item = _plansService.InsertPlanType(model); return Request.CreateResponse(response); }
public int InsertPlanType(PlanTypeAddRequest model) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.PlanTypes_Insert" , inputParamMapper: delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Name", model.Name); 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; }