public async Task <IActionResult> PutUsersTest(int usersTestId, UsersTest usersTest)
        {
            if (usersTestId != usersTest.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutTest(int testId, Test test)
        {
            if (testId != test.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TestExists(testId))
                {
                    return(StatusCode(404));
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <Question> > PostQuestion(Question question)
        {
            _context.Question.Add(question);
            var result = await _context.SaveChangesAsync();

            if (result == 0)
            {
                return(StatusCode(500));
            }
            return(CreatedAtAction("GetQuestion", new { id = question.Id }, question));
        }
Esempio n. 4
0
        public async Task <ActionResult <User> > DeleteUser(string userId)
        {
            var user = await _context.User.FindAsync(userId);

            if (user == null)
            {
                return(NotFound());
            }

            _context.User.Remove(user);
            await _context.SaveChangesAsync();

            return(user);
        }
Esempio n. 5
0
        public async Task <ActionResult <Test> > PostTestAnswer([FromBody] Answer answer)
        {
            try
            {
                _context.Answer.Add(answer);

                await _context.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }

            return(StatusCode(201));
        }