public int Add(PaymentsAddRequest model, string userId) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.Payments_Insert" , inputParamMapper: delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@LoanAmount", model.LoanAmount); paramCollection.AddWithValue("@LoanTerm", model.LoanTerm); paramCollection.AddWithValue("@LoanApr", model.LoanApr); paramCollection.AddWithValue("@PurchasePrice", model.PurchasePrice); paramCollection.AddWithValue("@CarMake", model.CarMake); paramCollection.AddWithValue("@CarModel", model.CarModel); paramCollection.AddWithValue("@CarYear", model.CarYear); paramCollection.AddWithValue("@CarCondition", model.CarCondition); paramCollection.AddWithValue("@UserId", userId); SqlParameter p = new SqlParameter("@id", System.Data.SqlDbType.Int); p.Direction = System.Data.ParameterDirection.Output; paramCollection.Add(p); }, returnParameters: delegate(SqlParameterCollection param) { Int32.TryParse(param["@id"].Value.ToString(), out id); } ); return id; }
public HttpResponseMessage PaymentsInsert(PaymentsAddRequest model) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } string userId = _userService.GetCurrentUserId(); ItemResponse<Int32> response = new ItemResponse<Int32>(); response.Item = _paymentsService.Add(model, userId); return Request.CreateResponse(response); }