public IHttpActionResult PutStudents(int id, Students students)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != students.Id)
            {
                return BadRequest();
            }

            db.Entry(students).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentsExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
 public void PutStudents(int id, Students students)
 {
     students.Id = id;
     if (!repository.Update(students))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
 }
        //public Students PostStudents(Students stut)
        //{
        //    stut = repository.Add(stut);
        //    return stut;
        //}

        public HttpResponseMessage PostStudents(Students stut)
        {
            stut = repository.Add(stut);
            var response = Request.CreateResponse<Students>(HttpStatusCode.Created, stut);

            string uri = Url.Link("DefaultApi", new { id = stut.Id });
            response.Headers.Location = new Uri(uri);
            return response;
        }
 public Students Add(Students stut)
 {
     if (stut == null)
     {
         throw new ArgumentNullException("stut");
     }
     stut.Id = _nextId++;
     students.Add(stut);
     return stut;
 }
        public IHttpActionResult PostStudents(Students students)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Student.Add(students);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = students.Id }, students);
        }
        public bool Update(Students stut)
        {
            if (stut == null)
            {
                throw new ArgumentNullException("item");
            }

            int index = students.FindIndex(p => p.Id == stut.Id);
            if (index == -1)
            {
                return false;
            }
            students.RemoveAt(index);
            students.Add(stut);
            return true;
        }