示例#1
0
        public async Task SaveLibraryUpdateSuccess_Test()
        {
            Libraries library1 = new Libraries()
            {
                Id      = 1,
                Name    = "abc",
                Address = "123",
                Phone   = "123456789",
                Email   = "*****@*****.**"
            };

            _dbContext.Set <Libraries>().Add(library1);

            LibraryViewModel model = new LibraryViewModel()
            {
                Id      = 1,
                Name    = "abc123",
                Address = "123",
                Phone   = "123456789",
                Email   = "*****@*****.**"
            };

            await _dbContext.SaveChangesAsync();

            var efRepository       = new EfRepository <Libraries>(_dbContext);
            var saveLibraryCommand = new SaveLibraryCommand(efRepository);
            var result             = await saveLibraryCommand.ExecuteAsync(model);

            var getListLibrary = new GetListLibraryQuery(efRepository);
            var library        = (await getListLibrary.ExecuteAsync()).FirstOrDefault();

            Assert.Equal(result.Data, model.Id);
            Assert.Equal(model.Name, library.Name);
        }
示例#2
0
        public async Task <int> AddLibrary(LibraryViewModel entity)
        {
            var result = 0;

            using (var mediaContext = new MediaContext())
            {
                using (var transaction = mediaContext.Database.BeginTransaction())
                {
                    try
                    {
                        var library = new Library
                        {
                            Name = entity.Name
                        };
                        mediaContext.Libraries.Add(library);
                        await mediaContext.SaveChangesAsync();

                        result = library.Id;
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
            }
            return(result);
        }
示例#3
0
        public async Task <ActionResult> Library(string tabId, int parentId, int id, int?filterFileTypeId, string subFolder, bool allowUpload = true)
        {
            var result = SiteService.Library(id, subFolder);
            var model  = LibraryViewModel.Create(result, tabId, id, filterFileTypeId, allowUpload, LibraryMode.Site);

            return(await JsonHtml("Library", model));
        }
示例#4
0
        public App()
        {
            var tracksSerializer    = new iTunesXMLTracksDeserializer();
            var tracksRepository    = new SerializingTracksRepository(tracksSerializer);
            var playlistsRepository = new FakePlaylistsRepository(tracksRepository);

            var service = new LocalLibraryService(tracksRepository, tracksRepository);

            var audio         = new CSCoreAudioPlaybackEngine();
            var windowManager = new CustomWindowManager();
            var dialog        = new WindowsDialogService(windowManager);
            var proxy         = new LibraryViewModelsProxy(service, t => new TrackViewModel(t));
            //var tagger = new TagLibSharpAudioFileTagger();
            //var audioDurationCalc = new CSCoreAudioFileDurationCalculator();
            //var audioFIProvider = new LocalAudioFileInfoProvider(tagger, audioDurationCalc);

            var libraryVM   = new LibraryViewModel(proxy);
            var libraryView = new LibraryWindow()
            {
                DataContext = libraryVM
            };
            var libraryConductor = new CustomWindowManager.WindowConductor(libraryVM, libraryView);

            libraryView.ShowDialog();

            //var shellVM = new ShellViewModel(audio, service, dialog, libraryVM, new PlaybackControlsViewModel(audio, new PlaybackTimelineViewModel(audio)));
            //var shellView = new ShellWindow() { DataContext = shellVM };
            //var shellConductor = new CustomWindowManager.WindowConductor(shellVM, shellView);
            //shellView.ShowDialog();

            this.Shutdown();
        }
示例#5
0
        private async Task TestUpdateFromConfig(LibraryViewModel library, ListSortDirection direction, string property)
        {
            ConfigStorage.Instance.ViewConfig.LibraryFilter.SortDescription = new SortDescription()
            {
                Direction = direction, PropertyName = property
            };
            var lastErrorMessage = string.Empty;

            void OnLogReceived(LogEventStruct les)
            {
                if (les.Level == "Error")
                {
                    lastErrorMessage = les.FormattedMessage;
                }
            }

            Log.LogReceived += OnLogReceived;
            await library.Update().ConfigureAwait(false);

            Log.LogReceived -= OnLogReceived;
            if (!string.IsNullOrWhiteSpace(lastErrorMessage))
            {
                Assert.Fail(lastErrorMessage);
            }
        }
示例#6
0
 public TaskbarIconModel(object icon, LibraryViewModel library)
 {
     this.icon = icon as TaskbarIcon;
       this.ContextMenu = new ObservableCollection<ContentMenuItem>();
       this.DoubleClickCommand = new ShowMainWindowCommand();
       NotifyIconInitialize(library);
 }
示例#7
0
        public IActionResult Index(string author, string bookTitle)
        {
            var model = new LibraryViewModel();

            model.Books = bookData.GetBooks(author, bookTitle);
            return(View(model));
        }
示例#8
0
 public Library(User currentUser)
 {
     InitializeComponent();
     this.currentUser = currentUser;
     libraryViewModel = new LibraryViewModel(currentUser);
     this.DataContext = libraryViewModel;
 }
示例#9
0
        public AddReport(IList <LibraryViewModel> libraryItems, LibraryViewModel selectedItem) : this(libraryItems)
        {
            this.selectedItem     = selectedItem;
            Library.SelectedValue = selectedItem.Id;

            addBtn.Content = Constants.EDIT;
        }
        public LibraryPage()
        {
            this.InitializeComponent();

            _viewModel       = new LibraryViewModel();
            this.DataContext = _viewModel;
        }
示例#11
0
        /// <summary>
        /// Attempts to unlock the provided cheat.
        /// </summary>
        /// <param name="cheat">The cheat to unlock</param>
        private void UnlockCheat(Cheat cheat)
        {
            if (!this.LockedCheatList.Contains(cheat))
            {
                throw new Exception("Cheat must be a locked cheat");
            }

            AccessTokens accessTokens = SettingsViewModel.GetInstance().AccessTokens;

            // We need the unlocked cheat, since the locked one does not include the payload
            try
            {
                UnlockedCheat unlockedCheat = SqualrApi.UnlockCheat(accessTokens.AccessToken, cheat.CheatId);

                BrowseViewModel.GetInstance().SetCoinAmount(unlockedCheat.RemainingCoins);

                this.LockedCheatList.Remove(cheat);
                this.UnlockedCheatList.Insert(0, unlockedCheat.Cheat);
                LibraryViewModel.GetInstance().OnUnlock(unlockedCheat.Cheat);
            }
            catch (Exception ex)
            {
                OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Error unlocking cheat", ex);
            }
        }
示例#12
0
        public LibraryIconSelectorControl(LibraryViewModel viewModel, Window userInterface)
        {
            InitializeComponent();

            _userInterface        = userInterface;
            _viewModel            = viewModel;
            _currentIconReference = _viewModel.IconReference;
            _browseCommand        = new Commands.BrowseCommand(this);
            _availableIcons       = new ObservableCollection <AvailableIcon>();
            _defaultIconPath      = String.Format(@"{0}windows\system32\imageres.dll", Environment.SystemDirectory.Substring(0, 3).ToLowerInvariant());

            tipText.Inlines.Add("Tip: Try browsing ");

            Run       linkText = new Run(_defaultIconPath);
            Hyperlink link     = new Hyperlink(linkText);

            //link.NavigateUri = new Uri(webAddress.Text);
            link.Click += new RoutedEventHandler(link_Click);
            tipText.Inlines.Add(link);
            tipText.Inlines.Add(".");

            AddDefaultIcons();

            // add the icon(s) from the referenced file, unless it is one of the defaults.
            if (!IsBuiltInLibraryIcon(_currentIconReference))
            {
                AddIcons(_currentIconReference.ModuleName);
            }

            base.DataContext = this;
        }
示例#13
0
        public ActionResult RegisterBooks(string mode, string id)
        {
            LibraryViewModel lvModel = new LibraryViewModel();

            lvModel.MODE = mode;
            if (mode != null && string.Equals(mode, "EDIT", StringComparison.OrdinalIgnoreCase))
            {
                //Populate edit data using id passed in URL, if id==null then show error message
                StatusDTO <BookMasterDTO> dto = _bookmasterSvc.Select(Convert.ToInt32(id));
                lvModel.BookMasterId   = dto.ReturnObj.BookMasterId;
                lvModel.BookName       = dto.ReturnObj.BookName;
                lvModel.AuthorName1    = dto.ReturnObj.AuthorName1;
                lvModel.AuthorName2    = dto.ReturnObj.AuthorName2;
                lvModel.PurchaseDate   = dto.ReturnObj.PurchaseDate;
                lvModel.AccNo          = dto.ReturnObj.AccNo;
                lvModel.AccDate        = dto.ReturnObj.AccDate;
                lvModel.CALLNO         = dto.ReturnObj.CALLNO;
                lvModel.ISBNNo         = dto.ReturnObj.ISBNNo;
                lvModel.Edition        = dto.ReturnObj.Edition;
                lvModel.Publisher      = dto.ReturnObj.Publisher;
                lvModel.PublishingYear = dto.ReturnObj.PublishingYear;
                lvModel.Place          = dto.ReturnObj.Place;
                lvModel.Series         = dto.ReturnObj.Series;
                lvModel.Price          = dto.ReturnObj.Price;
                lvModel.NOFCD          = dto.ReturnObj.NOFCD;
                lvModel.BookCategory   = dto.ReturnObj.BookCategory;
                lvModel.Location       = dto.ReturnObj.Location;
            }
            lvModel.BookCategoryList = _uiddlRepo.getBookCategoryDropDown();
            lvModel.LocationList     = _uiddlRepo.getLocationDropDown();
            return(View(lvModel));
        }
示例#14
0
        public async Task <IActionResult> Index()
        {
            //Get Menu
            ViewBag.MenuMachine = await _repoWrapper.ProductCategory.GetLstMenuByParentId(654);

            ViewBag.MenuMaterials = await _repoWrapper.ProductCategory.GetLstMenuByParentId(652);

            ViewBag.MenuServices = await _repoWrapper.ProductCategory.GetLstMenuByParentId(651);

            ViewBag.MenuHeader = await _repoWrapper.Video.GetLstVideoCate();

            ViewBag.MetaTags = await _repoWrapper.Setting.GetSetting();

            LibraryViewModel libraryViewModel = new LibraryViewModel();

            //Khối kiến thức vận hành
            libraryViewModel.lstLib1 = await _repoWrapper.Library.GetLstLibByCate(2, 1, 7);

            libraryViewModel.CateName1 = await _repoWrapper.Library.LibraryCategoryById(2);

            //Khối kiến thức bảo dưỡng
            libraryViewModel.lstLib2 = await _repoWrapper.Library.GetLstLibByCate(3, 1, 7);

            libraryViewModel.CateName2 = await _repoWrapper.Library.LibraryCategoryById(3);

            //Khối tin sửa chữa
            libraryViewModel.lstLib3 = await _repoWrapper.Library.GetLstLibByCate(4, 1, 7);

            libraryViewModel.CateName3 = await _repoWrapper.Library.LibraryCategoryById(4);

            return(View(libraryViewModel));
        }
示例#15
0
        private void AddReportBtn_Click(object sender, RoutedEventArgs e)
        {
            InitDataSource(ref reportItems, Mapper.ReportsToReportViewModels, reportController.Get);

            AddReport addReport = new AddReport(libraryItems);

            if (addReport.ShowDialog().Value)
            {
                LibraryViewModel model = addReport.SelectedItem;

                if (model != null)
                {
                    Library library = libraryController.GetById(model.Id);
                    Report  report  = new Report(library);
                    report.CountClients       = clientController.CountByLibraryId(library.Id);
                    report.CountSections      = sectionController.CountByLibraryId(library.Id);
                    report.CountBooks         = bookController.CountByLibraryId(library.Id);
                    report.CountBooksInUse    = bookClientController.CountInUseByLibraryId(library.Id);
                    report.CountBooksNotInUse = report.CountBooks - report.CountBooksInUse;

                    reportController.Add(report);
                    reportItems.Add(Mapper.ReportToReportViewModel(report));
                    return;
                }
            }
        }
示例#16
0
        public void AddSelectedSwatches(LibraryViewModel fromLibrary, LibraryViewModel toLibrary)
        {
            Logger.Log.Debug("Adding");

            for (int i = fromLibrary.Swatches.Count - 1; i > -1; i--)
            {
                if (fromLibrary.Swatches[i].IsSelected)
                {
                    if (toLibrary.Swatches.Where(s => s.Color == fromLibrary.Swatches[i].Color).Any())
                    {
                        //MessageBox.Show(String.Format("{0} already exists in {1}", fromLibrary.Swatches[i].Color.ToString().Substring(3).Insert(0, "#"), toLibrary.Name));
                        continue;
                    }

                    var swatch          = new Swatch(fromLibrary.Swatches[i].Color);
                    var swatchViewModel = new SwatchViewModel(MainViewModel, swatch);

                    toLibrary.Library.Swatches.Add(swatch);

                    toLibrary.Swatches.Add(swatchViewModel);
                }
            }

            toLibrary.IsDirty = true;
        }
示例#17
0
        private void EditReportBtn_Click(object sender, RoutedEventArgs e)
        {
            ReportViewModel reportVM = dataGrid.SelectedItem as ReportViewModel;

            AddReport editReport = new AddReport(libraryItems, libraryItems.First(i => i.Id == reportVM.LibraryId));

            if (editReport.ShowDialog().Value)
            {
                LibraryViewModel model = editReport.SelectedItem;

                if (reportVM != null && model != null)
                {
                    Report  report  = reportController.GetById(reportVM.Id);
                    Library library = libraryController.GetById(model.Id);
                    reportVM.LibraryId        = library.Id;
                    report.Library            = library;
                    report.CountClients       = clientController.CountByLibraryId(library.Id);
                    report.CountSections      = sectionController.CountByLibraryId(library.Id);
                    report.CountBooks         = bookController.CountByLibraryId(library.Id);
                    report.CountBooksInUse    = bookClientController.CountInUseByLibraryId(library.Id);
                    report.CountBooksNotInUse = report.CountBooks - report.CountBooksInUse;

                    reportController.Edit(report);
                }
            }
        }
示例#18
0
 public Library()
 {
     this.InitializeComponent();
     _navigationHandler = NavigationHandler.Instance;
     _libraryViewModel  = DataContext as LibraryViewModel;
     _gameList          = GameList.Instance;
 }
示例#19
0
        private void combine_instruction_and_library_data()
        {
            // Load the global models
            LibraryViewModel global_library_list = (LibraryViewModel)this.FindResource("library_view_model");

            /*
             * Iterate through each instruction and set the library name for it.
             *
             * This will probably be slow...
             */
            foreach (Instruction i in instruction_view_model.Model)
            {
                foreach (Library l in global_library_list.Model)
                {
                    if (l.Address_execution <= i.Address_execution && i.Address_execution < (l.Address_execution + l.Size_execution))
                    {
                        i.Library_name = l.Library_name;

                        foreach (KeyValuePair <string, uint> export in l.Exports)
                        {
                            if (i.Address_execution - l.Address_execution == export.Value)
                            {
                                i.System_call_name = export.Key;
                            }
                        }

                        i.Address_disk = i.Address_execution - l.Address_execution + l.Address_disk;

                        break;
                    }
                }
            }
        }
        //GET: /Select user/

        public IActionResult Select(int id)
        {
            var newuser = (from Reader item in _context.Reader
                           where item.ReaderID == id
                           select item).FirstOrDefault();

            var bookoflist = from n in _context.BookC
                             where n.RentedbyReader == newuser.ReaderID
                             select n;
            var bookVM = new LibraryViewModel
            {
                BookCs = bookoflist.ToList()
            };

            if (bookoflist.ToList().Count != 0)
            {
                ViewBag.Nameuser    = newuser.Name;
                ViewBag.Surnameuser = newuser.Surname;
                ViewBag.ReturnDate  = bookoflist.FirstOrDefault().RentData.AddDays(14);
            }
            else
            {
                ViewBag.Nameuser    = newuser.Name;
                ViewBag.Surnameuser = newuser.Surname;
                ViewBag.ReturnDate  = " ";
            }
            return(View(bookVM));
        }
示例#21
0
 public Upload(User currentUser, LibraryViewModel libraryViewModel)
 {
     InitializeComponent();
     trainingRestClient    = new TrainingRestClient(currentUser.Id);
     this.currentUser      = currentUser;
     this.libraryViewModel = libraryViewModel;
 }
示例#22
0
        public LibraryView(LibraryViewModel viewModel)
        {
            this.DataContext = viewModel;

            // CEF should already be initiallized if running within Revit
            if (!Cef.IsInitialized)
            {
                var settings = new CefSettings {
                    RemoteDebuggingPort = 8088
                };

                // Matching Revit 2020 CefSharp Initialization Settings:
                CefSharpSettings.LegacyJavascriptBindingEnabled      = true;
                CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
                CefSharpSettings.ShutdownOnExit = false;
                //https://bitbucket.org/chromiumembedded/cef/issues/2214/osr-scroll-is-erratic-after-using-mouse#comment-46738015
                //https://github.com/cefsharp/CefSharp/issues/2408
                //TODO remove in 67 or up.
                settings.DisableTouchpadAndWheelScrollLatching();

                Cef.Initialize(settings);
            }

            InitializeComponent();

            this.Browser.MenuHandler = new LibraryViewContextMenuHandler();
        }
示例#23
0
        [SuppressMessage("ReSharper", "SuggestBaseTypeForParameter")]// needed for DI
        public MainViewModel(
            Configuration config,
            ShortcutManager shortcutManager, // manually injecting all tabs for now,
            SourcesViewModel sourcesVm,      // might want to replace this if more tabs get added
            ConfigurationViewModel configuration,
            DownloaderViewModel downloader,
            LibraryViewModel library)
        {
            DisplayName          = WindowTitleBase;
            TabClosing           = OnTabClosing;
            this.config          = config;
            this.shortcutManager = shortcutManager;
            CreateShortcuts();
            Items.AddRange(new TabViewModelBase[]
            {
                library,
                downloader,
                sourcesVm,
                configuration,
            });

            library.ConductWith(this);
            downloader.ConductWith(this);
            sourcesVm.ConductWith(this);
            configuration.ConductWith(this);

            var tabId = config.State.ActiveTab ?? string.Empty;
            var tab   = Items.FirstOrDefault(t => t.Id == tabId);

            if (tab != null)
            {
                ActivateItem(tab);
            }
        }
示例#24
0
        // GET: MyLibrary
        public ActionResult Index()
        {
            LibraryViewModel myLib = new LibraryViewModel();

            using (VBSContext db = new VBSContext())
            {
                myLib.MySelectedBooks = db.Libraries
                                        .Include(s => s.Book)
                                        .Include(a => a.Book.Authors)
                                        .Include(c => c.Book.Categories)
                                        .Include(l => l.Book.Languages)
                                        .AsQueryable()
                                        .Where(x => x.UserId == CurrentSession.User.Id)
                                        .Where(d => d.DeletedAt.Equals(null))
                                        .ToList();

                myLib.MyDeletedSelectedBooks = db.Libraries
                                               .Include(s => s.Book)
                                               .Include(a => a.Book.Authors)
                                               .Include(c => c.Book.Categories)
                                               .Include(l => l.Book.Languages)
                                               .AsQueryable()
                                               .Where(x => x.UserId == CurrentSession.User.Id)
                                               .Where(d => !d.DeletedAt.Equals(null))
                                               .ToList();
            }
            return(View(myLib));
        }
示例#25
0
        /// <summary>
        /// Creates and add the library view to the WPF visual tree
        /// </summary>
        /// <returns>LibraryView control</returns>
        internal LibraryView AddLibraryView()
        {
            var sidebarGrid = dynamoWindow.FindName("sidebarGrid") as Grid;
            var model       = new LibraryViewModel("http://localhost/library.html");
            var view        = new LibraryView(model);

            var browser = view.Browser;

            this.browser = browser;
            sidebarGrid.Children.Add(view);
            browser.RegisterAsyncJsObject("controller", this);
            //RegisterResources(browser);

            view.Loaded         += OnLibraryViewLoaded;
            browser.SizeChanged += Browser_SizeChanged;
            browser.LoadError   += Browser_LoadError;
            //wait for the browser to load before setting the resources
            browser.LoadingStateChanged += (sender, args) =>
            {
                //Wait for the Page to finish loading
                if (args.IsLoading == false)
                {
                    RegisterResources(browser);
                }
            };

            return(view);
        }
示例#26
0
 public MainWindowViewModel(DownloadsViewModel downloadsVM, LibraryViewModel libraryVM,
                            SettingsViewModel settingsVM)
 {
     DownloadsVM = downloadsVM;
     LibraryVM   = libraryVM;
     SettingsVM  = settingsVM;
 }
示例#27
0
        public async Task <bool> UpdateLibrary(LibraryViewModel entity)
        {
            var result = false;

            using (var mediaContext = new MediaContext())
            {
                using (var transaction = mediaContext.Database.BeginTransaction())
                {
                    try
                    {
                        var library = await mediaContext.Libraries.FirstOrDefaultAsync(x => x.Id == entity.Id);

                        library.Name = entity.Name;

                        mediaContext.Libraries.Add(library);
                        await mediaContext.SaveChangesAsync();

                        result = true;
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
            }
            return(result);
        }
示例#28
0
        private void EditSectionBtn_Click(object sender, RoutedEventArgs e)
        {
            SectionViewModel sectionVM = dataGrid.SelectedItem as SectionViewModel;

            AddSection editSection = new AddSection(libraryItems, sectionVM.Name, sectionVM.Description, libraryItems.First(i => i.Id == sectionVM.LibraryId));

            if (editSection.ShowDialog().Value)
            {
                string           name        = editSection.Name.Text;
                string           description = editSection.Description.Text;
                LibraryViewModel model       = editSection.SelectedItem;

                if (sectionVM != null && name != null && model != null)
                {
                    Models.Section section = sectionController.GetById(sectionVM.Id);
                    Library        library = libraryController.GetById(model.Id);
                    section.Name        = sectionVM.Name = name;
                    sectionVM.LibraryId = library.Id;
                    section.Library     = library;
                    section.Description = sectionVM.Description = description;
                    section.ModifiedOn  = sectionVM.ModifiedOn = DateTime.Now;
                    sectionController.Edit(section);
                }
            }
        }
示例#29
0
        public ActionResult Library(string tabId, int parentId, int id, int?filterFileTypeId, string subFolder, bool allowUpload = true)
        {
            var result = ContentService.Library(id, subFolder);
            var model  = LibraryViewModel.Create(result, tabId, id, filterFileTypeId, allowUpload, LibraryMode.Content);

            return(JsonHtml("Library", model));
        }
示例#30
0
        public async Task SaveLibraryInsertSuccess_Test()
        {
            LibraryViewModel model = new LibraryViewModel()
            {
                Id      = 0,
                Name    = "abc",
                Address = "123",
                Phone   = "123456789",
                Email   = "*****@*****.**",
                Enabled = true
            };

            var efRepository       = new EfRepository <Libraries>(_dbContext);
            var saveLibraryCommand = new SaveLibraryCommand(efRepository);
            var result             = await saveLibraryCommand.ExecuteAsync(model);

            var getListLibrary = new GetListLibraryQuery(efRepository);
            var library        = (await getListLibrary.ExecuteAsync()).FirstOrDefault();

            Assert.Equal(result.Data, model.Id);
            Assert.Equal(model.Name, library.Name);
            Assert.Equal(model.Address, library.Address);
            Assert.Equal(model.Phone, library.Phone);
            Assert.Equal(model.Email, library.Email);
            Assert.Equal(model.Enabled, library.Enabled);
        }