public IHttpActionResult GetLesson(int id) { String path = "Lessons\\" + id + ".txt"; if (!File.Exists(path)) { return(NotFound()); } Lesson lesson = new Lesson(); using (StreamReader sr = new StreamReader(path)) { lesson.Fill(sr.ReadLine()); while (!sr.EndOfStream) { lesson.AddItem(sr.ReadLine()); } } return(Ok(lesson)); }