public int AddAddress(AddressAddRequest model, string userId) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.Addresses_Insert" , inputParamMapper: delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Line1", model.Line1); paramCollection.AddWithValue("@Line2", model.Line2); paramCollection.AddWithValue("@City", model.City); paramCollection.AddWithValue("@State", model.State); paramCollection.AddWithValue("@Zip", model.Zip); paramCollection.AddWithValue("@Country", model.Country); 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) { int.TryParse(param["@Id"].Value.ToString(), out id); } ); return id; }
public HttpResponseMessage AddAddress(AddressAddRequest model) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } string userId = _userService.GetCurrentUserId(); ItemResponse<int> response = new ItemResponse<int>(); response.Item = _addressesService.AddAddress(model, userId); return Request.CreateResponse(response); }