public static int InsertEvents(EventsAddRequest model) { int eventId = 0; // DataProvider.ExecuteNonQuery(GetConnection, "dbo.Events_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@EventName", model.EventName); paramCollection.AddWithValue("@EventVenue", model.Venue); paramCollection.AddWithValue("@Date", model.Date); paramCollection.AddWithValue("@Phone", model.PhoneNumber); 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 eventId); } ); return(eventId); }
public HttpResponseMessage PostPerson(EventsAddRequest 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 <int> response = new ItemResponse <int>(); response.Item = EventsService.InsertEvents(model); return(Request.CreateResponse(model)); }