public IHttpActionResult PutStudent(int id, Student student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private static void TestValidatonAll()
        {
            using (var context = new InstituteEntities())
            {
                //create entity
                var student = context.Students.Create();
                student.StudentLastName   = "Siddiqi";
                student.GradePointAverage = 5;

                var department = context.Departments.Create();
                department.DepartmentName = "Electrical Engineering";

                //add it to context
                context.Students.Add(student);
                context.Departments.Add(department);

                try
                {
                    //save changes
                    context.SaveChanges();
                }
                catch (DbEntityValidationException validationException)
                {
                    //Console.WriteLine(validationException.)
                    string validationErrorMessage =
                        DbEntityValidationMessageParser.GetErrorMessage(validationException);

                    Console.WriteLine(validationErrorMessage);
                }
            }
        }