public int InsertNewListing(ListingsAddRequest model) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.Listings_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@RentCost", model.RentCost); paramCollection.AddWithValue("@LeaseTerms", model.LeaseTerms); paramCollection.AddWithValue("@AvailabilityDate", model.AvailabilityDate); paramCollection.AddWithValue("@Status", model.Status); paramCollection.AddWithValue("@HasParking", model.HasParking); paramCollection.AddWithValue("@UtilitiesIncluded", model.UtilitiesIncluded); paramCollection.AddWithValue("@Description", model.Description); paramCollection.AddWithValue("@Headline", model.Headline); SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int); p.Direction = ParameterDirection.Output; paramCollection.Add(p); }, returnParameters : delegate(SqlParameterCollection param) { int.TryParse(param["@Id"].Value.ToString(), out id); } ); return(id); }
public HttpResponseMessage EchoSearchValidation(ListingsAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); response.Item = _listingService.InsertNewListing(model); return(Request.CreateResponse(response)); }