コード例 #1
0
        /// <summary>
        /// Adds score and course details to existing student profile
        /// </summary>
        /// <param name="sId">student id</param>
        /// <param name="cId">course id of course taken by student</param>
        /// <param name="score">score obtained by student for particular course</param>
        public static void AddStudentScore(int sId, int cId, int score)
        {
            var student = GetStudentByStudentId(sId);
            var cs      = new CourseScore
            {
                StudentId = sId,
                CourseId  = cId,
                Score     = score
            };

            db.CourseScores.Add(cs);
            db.SaveChanges();
        }
コード例 #2
0
        public static CourseScore UpdateCourseScore(CourseScore updatedCourseScore)
        {
            var oldCourseScore =
                GetCourseScoreByScoreId(updatedCourseScore.Id);

            oldCourseScore.StudentId = updatedCourseScore.StudentId;
            oldCourseScore.CourseId  = updatedCourseScore.CourseId;
            oldCourseScore.Score     = updatedCourseScore.Score;


            db.SaveChanges();
            return(oldCourseScore);
        }