Skip to content

Instantly share code, notes, and snippets.

@davehax
Created April 20, 2018 06:08
Show Gist options
  • Save davehax/006f6baddac436583394a109752bd2fa to your computer and use it in GitHub Desktop.
Save davehax/006f6baddac436583394a109752bd2fa to your computer and use it in GitHub Desktop.
// Other using statements...
using Newtonsoft.Json.Linq;
// POST: api/AttendancesAPI/AddOrEditMultiple
[HttpPost, Route("api/AttendancesAPI/AddOrEditMultiple")]
[ActionName("AddOrEditMultiple")]
public HttpResponseMessage AddOrEditMultiple([FromBody]JToken attendanceProxy)
{
// JToken as a parameter type allows us to accept JSON
// We can then deserialise manually and handle errors
try
{
AttendanceProxy ap = attendanceProxy.ToObject<AttendanceProxy>();
// ...
return Request.CreateResponse(HttpStatusCode.OK);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment