public static async Task <HttpResponseMessage> GetNotes([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Note/List")][RequestBodyType(typeof(NoteBodyRequest), "NoteBodyRequest")] HttpRequestMessage req, TraceWriter log) { NoteBodyRequest notebodyreq = Converters.DeserializeFromJson <NoteBodyRequest>(req.Content.ReadAsStringAsync().Result); foreach (User u in UsersList) { if (u.UUID.Equals(notebodyreq.userUUID)) { return(req.CreateResponse(HttpStatusCode.OK, u.Notes.ToArray())); break; } } return(req.CreateResponse(HttpStatusCode.OK, new Note[1])); }
public static async Task <HttpResponseMessage> AddNote([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Note/Add")][RequestBodyType(typeof(NoteBodyRequest), "NoteBodyRequest")] HttpRequestMessage req, TraceWriter log) { /* * Edit note for a specific NoteUUID in URL and UserUUID Passed in BODY Request, receives also new informations in body. */ NoteBodyRequest notebodyreq = Converters.DeserializeFromJson <NoteBodyRequest>(req.Content.ReadAsStringAsync().Result); foreach (User u in UsersList) { if (u.UUID.Equals(notebodyreq.userUUID)) { Note n = new Note() { Content = notebodyreq.note.Content, LastEditTimeDate = notebodyreq.note.LastEditTimeDate, }; u.Notes.Add(n); return(req.CreateResponse(HttpStatusCode.OK, true)); } } return(req.CreateResponse(HttpStatusCode.OK, false)); }