using New_College.IServices; using New_College.Model.Models; using New_College.Services.BASE; using New_College.IRepository.Base; using New_College.Model.ViewModels; using System.Threading.Tasks; using System.Collections.Generic; using Newtonsoft.Json; using New_College.IRepository; using System.Linq; namespace New_College.Services { public class Test_QuestionInfoServices : BaseServices, ITest_QuestionInfoServices { private readonly IBaseRepository _dal; private readonly ITest_QuestionTypeInfoRepository _QuestionTypeInfoRepository; public Test_QuestionInfoServices(IBaseRepository dal , ITest_QuestionTypeInfoRepository ITest_QuestionTypeInfoRepository) { this._dal = dal; _QuestionTypeInfoRepository = ITest_QuestionTypeInfoRepository; base.BaseDal = dal; } /// /// 获取问题 /// /// /// public async Task> GetQuestion(appQuestionQuery query) { var info = await _dal.Query(x => x.IsDelete == false && x.CategoryId == query.CategoryId); if (info == null) return new List() { }; List list = new List() { }; //if (query.CategoryId == 20) //{ // List subject = new List() { "物理", "化学", "生物", "政治", "历史", "地理" }; // int sort = 1; // foreach (var x in subject) // { // foreach (var item in info) // { // list.Add(new appQuestionResult() // { // Id = item.Id, // IsAddScore = item.IsAddScore, // QuestionSort = sort++,// item.OrderSort, // QuestionTag = x, // QuestionTitle = "对于" + x + "," + item.QuestionTitle, // QuestionType = item.QuestionType, // QuestionTypeId = item.QuestionTypeId // }); // } // } // return list; //} int k = 0; foreach (var item in info) { k++; list.Add(new appQuestionResult() { Id = item.Id, IsAddScore = item.IsAddScore, QuestionSort = k, QuestionTag = item.QuestionTag, QuestionTitle = item.QuestionTitle, QuestionType = item.QuestionType, QuestionTypeId = item.QuestionTypeId }); } return list; } /// /// 获取mbti试题 /// /// public async Task> GetQuestionMBTI() { var info = await _dal.Query(x => x.IsDelete == false && x.CategoryId == 19); if (info == null) return new List() { }; return info.Select(s => new QuestionMBTI() { Answers = JsonConvert.DeserializeObject>(s.QuestionTag), QuestionSort = s.OrderSort, QuestionTitle = s.QuestionTitle }).ToList(); } } }