示例#1
0
 public async Task <List <UserVoc> > GetResults(UserNameVM userNameVM)
 {
     return(await appDbContext.UserVocs
            .Include(x => x.Voc)
            .Where(x => x.UserId == userNameVM.UserId)
            .ToListAsync());
 }
示例#2
0
        public async Task <List <VocCardVM> > GetTests(UserNameVM userNameVM)
        {
            List <VocCardVM> vocCardVMs = new List <VocCardVM>();
            List <UserVoc>   userVocs   = await appDbContext.UserVocs
                                          .Include(x => x.Voc)
                                          .Where(x => x.UserId == userNameVM.UserId && x.Study == true && x.NextReviewTime < DateTime.UtcNow)
                                          .ToListAsync();

            foreach (var userVoc in userVocs)
            {
                vocCardVMs.Add(new VocCardVM
                {
                    Voc         = await appDbContext.Vocs.FirstOrDefaultAsync(x => x.Id == userVoc.VocId),
                    UserVoc     = userVoc,
                    VocAudios   = await appDbContext.VocAudios.Where(x => x.VocId == userVoc.VocId).ToListAsync(),
                    Definitions = await appDbContext.Definitions.Where(x => x.VocId == userVoc.VocId).Include(e => e.Examples).ToListAsync(),
                    Images      = await appDbContext.Images.Where(x => x.VocId == userVoc.VocId).ToListAsync(),
                    Synonyms    = await appDbContext.Synonyms.Where(x => x.VocId == userVoc.VocId).ToListAsync(),
                    Translates  = await appDbContext.Translates.Where(x => x.VocId == userVoc.VocId).ToListAsync(),
                    Subtitles   = await GetSubtitles(userVoc.Voc)
                });
            }

            return(vocCardVMs);
        }
示例#3
0
        public async Task <List <VocCardVM> > GetVocCardVMs(UserNameVM userNameVM)
        {
            UserInfo userInfo = await appDbContext.UserInfos.FirstOrDefaultAsync(x => x.UserId == userNameVM.UserId);

            List <VocCardVM> vocCardVMs = new List <VocCardVM>();

            if (userInfo != null)
            {
                userNameVM.LastVocId = userInfo.LastVocId;
            }

            var vocs = await appDbContext.Vocs.Where(x => x.Id > userInfo.LastVocId).Take(50).ToListAsync();

            foreach (var voc in vocs)
            {
                vocCardVMs.Add(new VocCardVM
                {
                    Voc         = voc,
                    VocAudios   = await appDbContext.VocAudios.Where(x => x.VocId == voc.Id).ToListAsync(),
                    Definitions = await appDbContext.Definitions.Where(x => x.VocId == voc.Id).Include(e => e.Examples).ToListAsync(),
                    Synonyms    = await appDbContext.Synonyms.Where(x => x.VocId == voc.Id).ToListAsync(),
                    Translates  = await appDbContext.Translates.Where(x => x.VocId == voc.Id).ToListAsync()
                });
            }

            return(vocCardVMs);
        }
示例#4
0
        public async Task <List <VocCardVM> > GetVocCardVMs(UserNameVM userNameVM)
        {
            var response = await httpService.PostAsync <UserNameVM>(url, userNameVM);

            List <VocCardVM> vocCardVMs = new List <VocCardVM>();

            vocCardVMs = await DeserializeAsync <List <VocCardVM> >(response.HttpResponseMessage, defaultJsonSerializerOptions);

            return(vocCardVMs);
        }
        public async Task <UserVocListVM> GetUserVocVMsResults(UserNameVM userNameVM)
        {
            UserVocListVM userVocListVMs = new UserVocListVM();

            userVocListVMs.UserVocs = await appDbContext.UserVocs
                                      .Include(x => x.Voc)
                                      .Where(x => x.UserId == userNameVM.UserId)
                                      .ToListAsync();

            return(userVocListVMs);
        }
示例#6
0
        public async Task <UserVocListVM> GetUserVocVMsResults(UserNameVM userNameVM)
        {
            var response = httpService.Post($"{url}/GetUserVocVMsResults", userNameVM);

            UserVocListVM userVocListVMs = new UserVocListVM();

            userVocListVMs = await DeserializeAsync <UserVocListVM>(response.HttpResponseMessage, defaultJsonSerializerOptions);


            return(userVocListVMs);
        }
示例#7
0
        public async Task <VocMasterVM> GetVocMasterVM(UserNameVM userNameVM)
        {
            VocMasterVM vocMasterVM = new VocMasterVM();

            vocMasterVM.UserInfo = await appDbContext.UserInfos.FirstOrDefaultAsync(x => x.UserId == userNameVM.UserId);

            vocMasterVM.News = await GetNews(vocMasterVM.UserInfo);

            vocMasterVM.Studys = await GetStudys(userNameVM);

            vocMasterVM.Tests = await GetTests(userNameVM);

            vocMasterVM.Results = await GetResults(userNameVM);

            return(vocMasterVM);
        }
示例#8
0
        public List <VocCardVM> GetVocCardVMs(UserNameVM userNameVM)
        {
            var response = httpService.Post($"{url}/GetVocCardVMs", userNameVM);

            List <VocCardVM> VocCardVMs = new List <VocCardVM>();

            //if (response.Success)
            //{
            VocCardVMs = Deserialize <List <VocCardVM> >(response.HttpResponseMessage, defaultJsonSerializerOptions);
            //}
            //else
            //{
            //VocCardVMs.Add(new VocCardVM { Exception = response.HttpResponseMessage.Content.ToString() });
            //}

            return(VocCardVMs);
        }
示例#9
0
        public async Task <VocMasterVM> GetVocMasterVM(UserNameVM userNameVM)
        {
            var response = await httpService.PostAsync($"{url}/GetVocMasterVM", userNameVM);

            VocMasterVM vocMasterVM = new VocMasterVM();

            if (response.Success)
            {
                vocMasterVM = await DeserializeAsync <VocMasterVM>(response.HttpResponseMessage, defaultJsonSerializerOptions);
            }
            else
            {
                vocMasterVM.Exception = response.HttpResponseMessage.Content.ToString();
            }

            return(vocMasterVM);
        }
示例#10
0
        //public async Task<List<VocCardVM>> GetVocCardVMs()
        //{
        //    List<VocCardVM> vocCardVMs = new List<VocCardVM>();
        //    VocCardVM vocCardVM = new VocCardVM();
        //    vocCardVM.UserId = "e4b7bb16-7ebd-4b3c-9025-68af7e9f02f2";
        //    List<UserVoc> userVocs = new List<UserVoc>();

        //    userVocs = await appDbContext.UserVocs.Where(x => x.UserId == vocCardVM.UserId && x.Study == true).ToListAsync();

        //    foreach (var userVoc in userVocs)
        //    {
        //        vocCardVM.Voc = await appDbContext.Vocs.FirstOrDefaultAsync(x => x.Id == userVoc.VocId);
        //        vocCardVM.VocAudios = await appDbContext.VocAudios.Where(x => x.VocId == userVoc.VocId).ToListAsync();
        //        vocCardVM.Definitions = await appDbContext.Definitions.Where(x => x.VocId == userVoc.VocId).Include(e => e.Examples).ToListAsync();
        //        vocCardVM.Synonyms = await appDbContext.Synonyms.Where(x => x.VocId == userVoc.VocId).ToListAsync();
        //        vocCardVM.Translates = await appDbContext.Translates.Where(x => x.VocId == userVoc.VocId).ToListAsync();

        //        vocCardVMs.Add(vocCardVM);
        //    }

        //    return vocCardVMs;
        //}
        public async Task <List <VocCardVM> > GetVocCardVMs(UserNameVM userNameVM)
        {
            List <VocCardVM> vocCardVMs = new List <VocCardVM>();
            List <UserVoc>   userVocs   = await appDbContext.UserVocs.Where(x => x.UserId == userNameVM.UserId && x.Study == false).ToListAsync();

            foreach (var userVoc in userVocs)
            {
                vocCardVMs.Add(new VocCardVM
                {
                    Voc         = await appDbContext.Vocs.FirstOrDefaultAsync(x => x.Id == userVoc.VocId),
                    UserVoc     = userVoc,
                    VocAudios   = await appDbContext.VocAudios.Where(x => x.VocId == userVoc.VocId).ToListAsync(),
                    Definitions = await appDbContext.Definitions.Where(x => x.VocId == userVoc.VocId).Include(e => e.Examples).ToListAsync(),
                    Synonyms    = await appDbContext.Synonyms.Where(x => x.VocId == userVoc.VocId).ToListAsync(),
                    Translates  = await appDbContext.Translates.Where(x => x.VocId == userVoc.VocId).ToListAsync()
                });
            }

            return(vocCardVMs);
        }
        public async Task <ActionResult <VocMasterVM> > GetVocMasterVM(UserNameVM userNameVM)
        {
            try
            {
                if (userNameVM == null)
                {
                    return(BadRequest());
                }

                var user = await userManager.FindByNameAsync(userNameVM.UserName);

                userNameVM.UserId = user.Id;

                return(await vocMasterRepository.GetVocMasterVM(userNameVM));
            }
            catch (DbUpdateException Ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  Ex.InnerException.Message));
            }
        }
示例#12
0
        public async Task <ActionResult <List <VocCardVM> > > GetVocCardVMs(UserNameVM userNameVM)
        {
            try
            {
                var user = await userManager.FindByNameAsync(userNameVM.UserName);

                userNameVM.UserId = user.Id;

                var result = await picknewRepository.GetVocCardVMs(userNameVM);

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

                return(result);
            }
            catch (DbUpdateException Ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  Ex.InnerException.Message));
            }
        }