Beispiel #1
0
        Models.StudentAssessment IRepository.CreateStudentAssessment(Models.StudentAssessment model)
        {
            var parameters = new[] { new SqlParameter("@StudentId", model.StudentId.Value), new SqlParameter("@AssessmentTypeId", model.AssessmentTypeId.Value) };

            using (var db = new Db(ConnectionString))
            {
                model.Id = db.CallProcWithReturnValue(StoredProcedures.CreateStudentAssessment, parameters);
            }
            return(model);
        }
Beispiel #2
0
        Models.StudentAssessment IRepository.GetStudentAssessment(int id)
        {
            var result = new Models.StudentAssessment {
                Id = id
            };
            var parameters = new[] { new SqlParameter("@Id", id) };

            using (var db = new Db(ConnectionString))
            {
                db.UseDataReader(StoredProcedures.GetStudentAssessment, parameters, reader =>
                {
                    while (reader.Read())
                    {
                        result.StudentId          = reader.GetInt("StudentId");
                        result.AssessmentTypeId   = reader.GetInt("AssessmentTypeId");
                        result.StudentName        = reader.GetString("StudentName");
                        result.AssessmentTypeName = reader.GetString("AssessmentTypeName");
                    }
                });
            }
            return(result);
        }