public async Task<Result<AssignedClassData>> AssignedClass(int studentId) { using (SqlConnection con = new SqlConnection(_connectionString)) { AssignedClassData classData = await con.QueryFirstOrDefaultAsync<AssignedClassData>( @"select s.ClassId, s.ClassName from iti.vStudent s where s.StudentId = @StudentId;", new { StudentId = studentId }); if (classData == null) return Result.Failure<AssignedClassData>(Status.BadRequest, "Unknown Student."); return Result.Success(classData); } }
public async Task <Result <AssignedClassData> > AssignedClass(int teacherId) { using (SqlConnection con = new SqlConnection(_connectionString)) { AssignedClassData classData = await con.QueryFirstOrDefaultAsync <AssignedClassData>( @"select c.ClassId, c.[Name] from iti.vTeacherClass c where c.TeacherId = @TeacherId;", new { TeacherId = teacherId }); if (classData == null) { return(Result.Failure <AssignedClassData>(Status.BadRequest, "Unknown teacher.")); } return(Result.Success(classData)); } }