I'm trying to understand how or what options are available for publishing the model class that is passed to my ASP.NET Web API CRUD methods. Here is an example of my POST method.
public HttpResponseMessage PostMaterial(Material material)
{
try
{
repository.Add(material);
}
catch (ArgumentNullException)
{
var exceptionResponse = Request.CreateResponse("Material object was null.");
return exceptionResponse;
}
var response = Request.CreateResponse("Material " + material.MaterialName + " created.");
string uri = Url.Link("DefaultApi", new { materialName = material.MaterialName });
response.Headers.Location = new Uri(uri);
return response;
}
In this example a material object is passed as a parameter when the method is called by an external API user. That caller would need a definition of the material class, so then could correctly build the object they will need to pass. If anyone has some details or a better explanation, then please let me know. I haven't had much luck finding an answer which leads me to believe I'm asking the wrong question.