public static void ModifyTheme(Enums.Theme _theme) { if (_theme == Enums.Theme.Dark) { theme.SetBaseTheme(Theme.Dark); } else { theme.SetBaseTheme(Theme.Light); } paletteHelper.SetTheme(theme); }
public async Task <MaterialsCollectionViewModel> GetMaterials( string searchText = null, Enums.Auditory auditory = Enums.Auditory.Common, Enums.Theme theme = Enums.Theme.Common, Enums.Type type = Enums.Type.Common, Enums.MaterialStatus status = Enums.MaterialStatus.All, int page = 0, Guid?userId = null, Enums.SortType sortType = Enums.SortType.AlphabetAsc, int count = 3) { var materials = await _unitOfWork.MaterialRepository.GetAll(); materials = materials.ToList(); if (status != Enums.MaterialStatus.All) { materials = materials.Where(m => m.Status == status).ToList(); } if (auditory != Enums.Auditory.Common) { materials = materials.Where(m => m.Auditory == auditory).ToList(); } if (type != Enums.Type.Common) { materials = materials.Where(m => m.Type == type).ToList(); } if (theme != Enums.Theme.Common) { materials = materials.Where(m => m.Theme == theme).ToList(); } if (!string.IsNullOrEmpty(searchText)) { materials = materials.Where(m => m.Name.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0 || m.Description.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0 || m.Theme.ToString("d").IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0); } if (userId != null) { materials = materials.Where(m => m.UserId == userId).ToList(); } if (sortType == Enums.SortType.AlphabetAsc) { materials = materials.OrderBy(m => m.Name).ToList(); } else if (sortType == Enums.SortType.AlphabetDesc) { materials = materials.OrderByDescending(m => m.Name).ToList(); } else if (sortType == Enums.SortType.DateAsc) { materials = materials.OrderBy(m => m.PublishingDate).ToList(); } else if (sortType == Enums.SortType.DateDesc) { materials = materials.OrderByDescending(m => m.PublishingDate).ToList(); } else if (sortType == Enums.SortType.RateAsc) { materials = materials.OrderByDescending(m => m.Rating).ToList(); } var materialsCount = materials.Count(); if (page != 0) { materials = materials.Skip(0).Take(count * page); } var uiMaterials = materials.Select(m => new MaterialViewModel { Id = m.Id, Name = m.Name, UserId = m.UserId, AuthorEmail = _unitOfWork.UserRepository.GetUserById(m.UserId).Email, AuthorName = _unitOfWork.UserRepository.GetUserById(m.UserId).Name, AuthorSurname = _unitOfWork.UserRepository.GetUserById(m.UserId).Surname, Description = m.Description, PublishingDate = m.PublishingDate, PublishingDateString = m.PublishingDate.ToString("dd.MM.yyyy"), Status = m.Status, StatusString = Constants.Status[(int)m.Status], Auditory = m.Auditory, Theme = m.Theme, ThemeString = Constants.Theme[(int)m.Theme], Type = m.Type, TypeString = Constants.Type[(int)m.Type], DownloadingLink = m.DownloadingLink, BytePicture = m.Picture, Base64Picture = Convert.ToBase64String(m.Picture), SourceOfInformation = m.SourceOfInformation, Rating = m.Rating, DownloadsCount = m.DownloadsCount }); return(new MaterialsCollectionViewModel { SearchText = searchText, Type = type, Theme = theme, ThemeString = Constants.Theme[(int)theme], Materials = uiMaterials, Page = page, TotalCount = materialsCount }); }