// GET: api/StudentApi/5 public StudentModel Get(int id) { StudentDto sd = new StudentDto(); return(sd.GetStudent().Find(student => student.Id == id)); //return "value"; }
// GET: api/StudentApi public List <StudentModel> Get() { StudentDto sd = new StudentDto(); return(sd.GetStudent()); //return new string[] { "value1", "value2" }; }
// DELETE: api/StudentApi/5 public IHttpActionResult Delete(int id) { StudentDto sd = new StudentDto(); if (sd.GetStudent().Find(student => student.Id == id) == null) { return(BadRequest("Not found")); } else { if (sd.DeleteStudent(id)) { return(Ok()); } } return(BadRequest()); }
// PUT: api/StudentApi/5 public IHttpActionResult Put(StudentModel student) { StudentDto sd = new StudentDto(); if (sd.GetStudent().Find(stud => stud.Id == student.Id) == null) { return(BadRequest("Not found")); } else { if (sd.UpdateStudent(student)) { return(Ok()); } } return(BadRequest()); }