Skip to content

Instantly share code, notes, and snippets.

@eulerfx
Created July 22, 2012 01:00
Show Gist options
  • Save eulerfx/3157819 to your computer and use it in GitHub Desktop.
Save eulerfx/3157819 to your computer and use it in GitHub Desktop.
public class ImportRequestModel
{
public string SupplierId { get; set; }
public string SeedFilePath { get; set; }
}
public class ImportController : ApiController
{
public ImportController(IBus bus)
{
this.bus = bus;
}
readonly IBus bus;
public HttpResponseMessage Post(ImportRequestModel request)
{
var taskId = Guid.NewGuid().ToString("N");
this.bus.Send<ImportProducts>(message =>
{
message.TaskId = taskId;
message.SupplierId = request.SupplierId;
message.SeedFilePath = request.SeedFilePath;
});
var response = new HttpResponseMessage(HttpStatusCode.Accepted);
response.Headers.Location = new Uri(string.Format("https://api.example.com/import/status/{0}", taskId));
return response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment