public MainPageViewModel(INavigationService navigationService, UserLibraryViewModel userLibaryViewModel, CatalogsViewModel catalogsViewModel, DataBaseInitializer dbInitialzier) { _navigationService = navigationService; _dbInitialzier = dbInitialzier; UserLibraryViewModel = userLibaryViewModel; CatalogsViewModel = catalogsViewModel; }
protected override void OnActivate() { base.OnActivate(); if (AppBarSelectedIndex == 1) { CatalogsViewModel.LoadData(); } UserLibraryViewModel.LoadData(); }
protected async override void OnViewLoaded(object view) { base.OnViewLoaded(view); if (AppSettings.Default.IsFirstTimeRunning) { await _dbInitialzier.ExecuteAsync(); AppSettings.Default.IsFirstTimeRunning = false; } CatalogsViewModel.LoadData(); }
public IActionResult GetCatalogs() { var sdls = _unitOfWork.Employee.Entities.Where(e => e.IsServiceDeliveryManager == true).Select(c => new CatalogViewModel(c.Id, c.Alias)).ToList(); sdls.Add(new CatalogViewModel(-1, "ALL")); var catalogs = new CatalogsViewModel { SDLS = sdls, AMS = _unitOfWork.Employee.Entities.Where(e => e.IsAccountManager == true).Select(c => new CatalogViewModel(c.Id, c.Alias)).ToList(), Clients = _unitOfWork.Company.Entities.Select(c => new CatalogViewModel(c.Id, c.Name)).ToList(), Bls = _unitOfWork.BL.Entities.Select(c => new CatalogViewModel(c.Id, c.Name)).ToList(), Countries = _unitOfWork.Country.Entities.Select(c => new CatalogViewModel(c.Code, c.Code)).ToList(), Currencies = _unitOfWork.Currency.Entities.Select(c => new CatalogViewModel(c.Code, c.Code)).ToList(), Employees = _unitOfWork.Employee.Entities.Where(e => e.IsEngineer == true).Select(e => new CatalogViewModel(e.Id, e.FullName1)).ToList(), CostTypes = _unitOfWork.CostType.Entities.Select(c => new CatalogViewModel(c.Id, c.Name)).ToList(), Portfolios = _unitOfWork.Portfolio.Entities.Select(c => new CatalogViewModel(c.Id, c.Name)).ToList(), Subportfolios = _unitOfWork.Subportfolio.Entities.Select(s => new CatalogViewModel(s.Id, s.Name)).ToList(), }; return(Ok(catalogs)); }
public async Task <IActionResult> Index(string searchName = "") { var allCatalogs = _dbContext.Catalogs.ToList(); var model = new CatalogsAllViewModel() { Catalogs = new List <CatalogsViewModel>() }; if (!CheckWhetherCurrentUserIsAdmin()) { allCatalogs = allCatalogs.Where(x => x.MyUserId == GetCurrentUserId()).ToList(); } if (searchName != null && searchName != "") { allCatalogs = allCatalogs.Where(x => x.Name.Contains(searchName)).ToList(); } foreach (var catalog in allCatalogs) { int songsCount = _dbContext.CatalogSong.Where(x => x.CatalogId == catalog.Id).Count(); var singleViewModel = new CatalogsViewModel() { Id = catalog.Id, Name = catalog.Name, Descritpion = catalog.Description, MyUserId = catalog.MyUserId, MyUserName = (await _dbContext.Users.FindAsync(catalog.MyUserId)).UserName, SongsCount = songsCount }; model.Catalogs.Add(singleViewModel); } return(View(model)); }