示例#1
0
        // GET: api/StudentApi/5
        public StudentModel Get(int id)
        {
            StudentDto sd = new StudentDto();

            return(sd.GetStudent().Find(student => student.Id == id));
            //return "value";
        }
示例#2
0
        // GET: api/StudentApi
        public List <StudentModel> Get()
        {
            StudentDto sd = new StudentDto();

            return(sd.GetStudent());
            //return new string[] { "value1", "value2" };
        }
示例#3
0
        // 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());
        }
示例#4
0
        // 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());
        }