Ejemplo n.º 1
0
 public IHttpActionResult Post(ProductListingAddRequest model)
 {
     try
     {
         ItemResponse <int> response = new ItemResponse <int>
         {
             Item         = _productListingService.Insert(model),
             IsSuccessful = true
         };
         return(Ok(response));
     }
     catch (Exception ex) { return(BadRequest(ex.Message)); }
 }
        public int Insert(ProductListingAddRequest model)
        {
            int id = 0;

            Adapter.ExecuteQuery("Product_Listing_Insert", new[] {
                SqlDbParameter.Instance.BuildParameter("@Price", model.Price, System.Data.SqlDbType.NVarChar),
                SqlDbParameter.Instance.BuildParameter("@UserBaseId", model.UserBaseId, System.Data.SqlDbType.Int),
                SqlDbParameter.Instance.BuildParameter("@UrlLocation", model.UrlLocation, System.Data.SqlDbType.NVarChar),
                SqlDbParameter.Instance.BuildParameter("@Id", id, System.Data.SqlDbType.Int, 0, ParameterDirection.Output)
            }, (parameters =>
            {
                id = parameters.GetParmValue <int>("@Id"); //for inserts
            }));
            return(id);
        }