Exemplo n.º 1
0
        public async Task <bool> DeleteTagAsync([Service] TestSystemDbContext context, Guid id)
        {
            var state = context.Tags.Remove(await context.Tags.FindAsync(id)).State;
            await context.SaveChangesAsync();

            return(state == EntityState.Deleted ? true : false);
        }
Exemplo n.º 2
0
        public async Task <Tag> UpdateTagAsync([Service] TestSystemDbContext context, Tag updateTag)
        {
            var tag = context.Tags.Update(updateTag);
            await context.SaveChangesAsync();

            return(tag.Entity);
        }
Exemplo n.º 3
0
 public AccountService(TestSystemDbContext context, UserManager <User> userManager,
                       SignInManager <User> signInManager)
 {
     _context       = context;
     _userManager   = userManager;
     _signInManager = signInManager;
 }
        public async Task <Test> UpdateTestAsync([Service] TestSystemDbContext context, Test updateTest)
        {
            var test = context.Tests.Update(updateTest);
            await context.SaveChangesAsync();

            return(test.Entity);
        }
Exemplo n.º 5
0
        public async Task <Question> UpdateQuestionAsync([Service] TestSystemDbContext context, Question updateQuestion)
        {
            var question = context.Update(updateQuestion);
            await context.SaveChangesAsync();

            return(question.Entity);
        }
Exemplo n.º 6
0
        public async Task <Question> CreateQuestionAsync([Service] TestSystemDbContext context, Question questionInput)
        {
            var question = await context.Questions.AddAsync(questionInput);

            await context.SaveChangesAsync();

            return(question.Entity);
        }
        public async Task <bool> RemoveQuestionsAsync([Service] TestSystemDbContext context, TestQuestionRelation testQuestions)
        {
            testQuestions.TestsQuestions.ToList().ForEach(x => x.TestId = testQuestions.TestId);
            context.TestQuestion.RemoveRange(testQuestions.TestsQuestions);
            await context.SaveChangesAsync();

            return(true);
        }
Exemplo n.º 8
0
        public async Task <bool> RemoveTagsAsync([Service] TestSystemDbContext context, TagQuestionRelation tagQuestion)
        {
            tagQuestion.QuestionsTags.ToList().ForEach(x => x.QuestionId = tagQuestion.QuestionId);
            context.QuestionTag.RemoveRange(tagQuestion.QuestionsTags);
            await context.SaveChangesAsync();

            return(true);
        }
Exemplo n.º 9
0
        public async Task <Tag> CreateTagAsync([Service] TestSystemDbContext context, Tag inputTag)
        {
            var tag = await context.Tags.AddAsync(inputTag);

            await context.SaveChangesAsync();

            return(tag.Entity);
        }
        public async Task <bool> AddTagsAsync([Service] TestSystemDbContext context, TagTestRelation tagTest)
        {
            tagTest.TestsTags.ToList().ForEach(x => x.TestId = tagTest.TestId);
            context.TestTag.AddRange(tagTest.TestsTags);
            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <Test> CreateTestAsync([Service] TestSystemDbContext context, Test testInput)
        {
            testInput.CreateDate = DateTime.Now;
            var test = context.Tests.Add(testInput);
            await context.SaveChangesAsync();

            return(test.Entity);
        }
Exemplo n.º 12
0
        public async Task <bool> DeleteQuestionAsync([Service] TestSystemDbContext context, Guid id)
        {
            var state = context.Questions.Remove(await context.Questions.FindAsync(id)).State;
            await context.SaveChangesAsync();

            var result = state == EntityState.Deleted ? true : false;

            return(result);
        }
Exemplo n.º 13
0
        public void TestSignInValidUser(string email, string password)
        {
            var loginUserModel = new LoginModel()
            {
                Email = email, Password = password
            };
            var options = SetUpInMemoryDbOptions();

            using (var context = new TestSystemDbContext(options))
            {
            }
        }
Exemplo n.º 14
0
 public async Task <Result> GetResultAsync([Service] TestSystemDbContext context, Guid id)
 {
     return(await context.Results.FindAsync(id));
 }
Exemplo n.º 15
0
 public async Task <Question> GetQuestionAsync([Service] TestSystemDbContext context, Guid id)
 {
     return(await context.Questions.FindAsync(id));
 }
Exemplo n.º 16
0
 public async Task <IEnumerable <Question> > GetQuestionsAsync([Service] TestSystemDbContext context)
 {
     return(await context.Questions.ToListAsync());
 }
Exemplo n.º 17
0
 public async Task <Tag> GetTagAsync([Service] TestSystemDbContext context, Guid id)
 {
     return(await context.Tags.FindAsync(id));
 }
Exemplo n.º 18
0
 public async Task <IEnumerable <Tag> > GetTagsAsync([Service] TestSystemDbContext context)
 {
     return(await context.Tags.ToListAsync());
 }
Exemplo n.º 19
0
 public async Task <IEnumerable <Result> > GetResultsAsync([Service] TestSystemDbContext context)
 {
     return(await context.Results.ToListAsync());
 }