Created
April 20, 2018 06:08
-
-
Save davehax/006f6baddac436583394a109752bd2fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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