예제 #1
0
        public async Task <IActionResult> PutMtc([FromRoute] int id, [FromBody] Mtc mtc)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mtc.Gid)
            {
                return(BadRequest());
            }

            _context.Entry(mtc).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MtcExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PostMtc([FromBody] Mtc mtc)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Mtcs.Add(mtc);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMtc", new { id = mtc.Gid }, mtc));
        }
예제 #3
0
 private void InitTestWithMultOp()
 {
     _settings            = new MtcSettings(5, 9, 10, 0, 0, false, MtcOperation.Multiplication, MtcDifficultyLevel.Normal);
     _questionListBuilder = new MtcQuestionListBuilder(_settings);
     _mtc = new Mtc(_settings, _questionListBuilder);
 }