コード例 #1
0
        public async Task <ActionResult> LibraryBook(string id = null)
        {
            LibraryBookViewModel viewModel = null;

            if (!string.IsNullOrEmpty(id))
            {
                LibraryBookResponse result = await _libraryBookClient.GetLibraryBookByLibraryBookCode(id);

                if (result.StatusIsSuccessful)
                {
                    viewModel = LibraryBookViewModel.CreateLibraryBookViewModel(result.Data);
                }
                else
                {
                    AddResponseErrorsToModelState(result);
                }
            }

            if (viewModel == null)
            {
                viewModel = new LibraryBookViewModel();
            }



            return(View(viewModel));
        }
コード例 #2
0
        private async Task <(LibraryBookApiModel libraryBook, LibraryUserApiModel libraryuser)> GetBookAndUser(string libraryBookCode, string libraryUserCode)
        {
            LibraryBookApiModel libraryBook = null;
            LibraryUserApiModel libraryuser = null;

            var(libraryBookResponse, libraryUserResponse) = await TaskEx.WhenAllTwo(_libraryBookClient.GetLibraryBookByLibraryBookCode(libraryBookCode), _libraryUserClient.GetLibraryUserByLibraryUserCode(libraryUserCode));

            if (libraryBookResponse.StatusIsSuccessful)
            {
                libraryBook = libraryBookResponse.Data;
            }
            else
            {
                AddResponseErrorsToModelState(libraryBookResponse);
            }
            if (libraryUserResponse.StatusIsSuccessful)
            {
                libraryuser = libraryUserResponse.Data;
            }
            else
            {
                AddResponseErrorsToModelState(libraryUserResponse);
            }

            return(libraryBook : libraryBook, libraryuser : libraryuser);
        }