public int Insert(RSVPTypesAddRequest myData) { int id = 0; DataProvider.ExecuteNonQuery("dbo.RSVPTypes_Insert", inputParamMapper: (SqlParameterCollection input) => { input.Add(SqlDbParameter.Instance.BuildParameter("@RSVPType", myData.RSVPType, SqlDbType.NVarChar, 50)); SqlParameter idOut = new SqlParameter("@Id", 0); idOut.Direction = ParameterDirection.Output; input.Add(idOut); }, returnParameters: (SqlParameterCollection inputs) => { int.TryParse(inputs["@Id"].Value.ToString(), out id); }); return(id); }
public IHttpActionResult Post(RSVPTypesAddRequest data) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ItemResponse <int> response = new ItemResponse <int> { Item = _Service.Insert(data) }; return(Ok(response)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }