private bool CanMenuAction(Button btn) { if (btn == null) { return(false); } //Disable button when not selected at main update source var mainUpdateSource = ApplicationContext.UpdateSourceList.FirstOrDefault(c => c.ParentId == 0); if (mainUpdateSource == null || ApplicationContext.SoftwareSelectedNodeId != mainUpdateSource.Id) { return(false); } //Count package selected var countSelected = ViewList.Count(r => r.IsSelected); switch (btn.Name) { //Allow delete many case UIConstant.BtnSoftwareDeletePackage: return(countSelected > 0); //Allow edit one case UIConstant.BtnSoftwareEditPackage: return(countSelected == 1); } return(true); }
public void GetData() { _comicBooks = _comicBookRepository.GetAll().Include(x => x.Series).Include(x => x.Series.Publisher).ToList(); if (PublisherId == 0) { ViewList = _comicBooks.Where(x => x.Title.Contains(SearchWord)).ToList(); } else if (PublisherId >= 1 && PublisherId <= 3) { ViewList = _comicBooks.Where(x => x.Series.Publisher.Id == PublisherId && x.Title.Contains(SearchWord)).ToList(); } else { ViewList = _comicBooks.Where(x => !Enumerable.Range(1, 3).Contains(x.Series.Publisher.Id) && x.Title.Contains(SearchWord)).ToList(); } NumberOfPages = (ViewList.Count() / 18) + 1; }