public IHttpActionResult Update(string sessionKey, int id, NoteModel noteModel)
        {
            var currentUser = this.GetUserBySessionKey(sessionKey);

            if (currentUser == null)
            {
                return BadRequest("Invalid user");
            }

            var existingNote = currentUser.Notes.FirstOrDefault(n => n.NoteId == id);

            if (existingNote == null)
            {
                return this.BadRequest("Note with this id does not exist.");
            }

            var updated = toNoteEntity(noteModel);
            existingNote = updated;
            this.data.SaveChanges();

            return Ok(existingNote);
        }
        public IHttpActionResult Create(string sessionKey, NoteModel noteModel)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var currentUser = this.GetUserBySessionKey(sessionKey);

            if (currentUser == null)
            {
                return BadRequest("Invalid user");
            }

            var newNote = toNoteEntity(noteModel);
            newNote.UserId = currentUser.UserId;

            this.data.Notes.Add(newNote);
            this.data.SaveChanges();

            noteModel.NoteId = newNote.NoteId;
            return Ok(noteModel);
        }