示例#1
0
        public async Task <VocMasterVM> UpdateVocMasterVM(VocMasterVM vocMasterVM)
        {
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// New
            if (vocMasterVM.News.Count > 0)
            {
                string userInfoUpdate = $@"UPDATE [dbo].[UserInfos]
                                                SET [LastVocId] = {vocMasterVM.UserInfo.LastVocId}                                                 
                                                WHERE [UserId] = '{vocMasterVM.UserInfo.UserId}';";

                string insertUserVoc = @"INSERT INTO [dbo].[UserVocs]
                                                ([UserId]
                                                ,[VocId]
                                                ,[Repetition]
                                                ,[Success]
                                                ,[NextReviewTime]
                                                ,[Study]
                                                ,[Level]
                                                ,[LevelCounter])
                                            VALUES";
                string values        = "";
                foreach (var nnew in vocMasterVM.News)
                {
                    nnew.UserVoc.UserId = vocMasterVM.UserInfo.UserId;

                    values += @$ ",('{nnew.UserVoc.UserId}'
                                , {nnew.UserVoc.VocId}
示例#2
0
        public async Task <VocMasterVM> UpdateVocMasterVM(VocMasterVM vocMasterVM)
        {
            var response = await httpService.Put <VocMasterVM>($"{url}/UpdateVocMasterVM", vocMasterVM);

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

            return(vocMasterVM);
        }
示例#3
0
        private async Task <VocMasterVM> CheckDeserialize(HttpResponseWrapper <object> httpResponseWrapper)
        {
            VocMasterVM vocMasterVM = new VocMasterVM();

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

            return(vocMasterVM);
        }
示例#4
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);
        }
示例#5
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);
        }
        public async Task <ActionResult <VocMasterVM> > UpdateVocMasterVM(VocMasterVM vocMasterVM)
        {
            try
            {
                if (vocMasterVM == null)
                {
                    return(BadRequest());
                }

                var user = await userManager.FindByNameAsync(vocMasterVM.UserInfo.UserName);

                vocMasterVM.UserInfo.UserId = user.Id;

                return(await vocMasterRepository.UpdateVocMasterVM(vocMasterVM));
            }
            catch (DbUpdateException Ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  Ex.InnerException.Message));
            }
        }