public static Entities.Question Map(Library.Models.Question question) => new Entities.Question { QuestionId = question.QuestionId, CategoryId = question.CategoryId, Question1 = question.QuestionString, Value = question.Value, //Category = Map(question.Category), francisco commented these out to be able to create new question without having to send category and choice objects //Choice = Map(question.QuestionChoices).ToList() otherwise, kept getting null values };
public async Task <int> CreateQuestion(Library.Models.Question question) { if (question is null) { throw new ArgumentNullException(nameof(question)); } _logger.LogInformation($"Adding question"); Entities.Question entity = Mapper.Map(question); _dbContext.Add(entity); await _dbContext.SaveChangesAsync(); return(question.QuestionId); }
public async void Check_GameMode() { IQuestionRepository sut6 = GetInMemoryQuestionRepository(); Library.Models.Question qA = new Library.Models.Question { QuestionId = 4, CategoryId = 1, QuestionString = "HelloSir?", Value = 10, }; int x = await sut6.CreateQuestion(qA); //int c1 = await sut5.CreateChoice(choiceA); //int c2 = await sut5.CreateChoice(choiceC); Library.Models.Question qB = await sut6.GetQuestionById(1); //Assert.True(gms.ToList().Count() == 1); Assert.True(qA.QuestionString == "HelloSir?"); //Assert.True(qA.QuestionString == "HelloSir?"); IEnumerable <Library.Models.Question> qs = sut6.GetQuestionsByCategoryId(1); bool hey = await sut6.DeleteQuestion(1); }