コード例 #1
0
    public async Task <AdminStipulatable> GetTest([FromBody] TestQuery login)
    {
        if (!await this.VerifySession(_manager) || !await this.VerifyAdmin(_query))
        {
            Response.StatusCode = 403;
            return(null);
        }

        var test = await _query.GetTest(login.TestID);

        if (test == null)
        {
            Response.StatusCode = 404;
            return(null);
        }

        var adminStipulatable = new AdminStipulatable(test);

        adminStipulatable.Validate(_config);
        return(adminStipulatable);
    }
コード例 #2
0
    public async Task <List <AdminStipulatable> > GetTests([FromBody] TestQuery login)
    {
        if (!await this.VerifySession(_manager) || !await this.VerifyAdmin(_query))
        {
            Response.StatusCode = 403;
            return(null);
        }

        var tests = await _query.GetAllTests();

        var validatedTests = new List <AdminStipulatable>();

        foreach (var test in tests)
        {
            var adminStipulatable = new AdminStipulatable(test);
            adminStipulatable.Validate(_config);
            validatedTests.Add(adminStipulatable);
        }

        return(validatedTests);
    }