public async Task <Tag> UpdateTagAsync([Service] TestSystemDbContext context, Tag updateTag) { var tag = context.Tags.Update(updateTag); await context.SaveChangesAsync(); return(tag.Entity); }
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); }
public async Task <Question> UpdateQuestionAsync([Service] TestSystemDbContext context, Question updateQuestion) { var question = context.Update(updateQuestion); await context.SaveChangesAsync(); return(question.Entity); }
public async Task <Test> UpdateTestAsync([Service] TestSystemDbContext context, Test updateTest) { var test = context.Tests.Update(updateTest); await context.SaveChangesAsync(); return(test.Entity); }
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> 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); }
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> 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 <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); }
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); }
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); }