Ejemplo n.º 1
0
        public async void LoadCategorie(bool reload = false)
        {
            if (reload || Categories == null || Categories?.Any() == false)
            {
                Categories = new BindableCollection <Button>();
                var cats = await DataHelpers.instanc().GetData <GroupeArticle>(a => true) as IEnumerable <GroupeArticle>;

                foreach (var item in cats)
                {
                    var btnCat = new Button();

                    btnCat.Content = item.Name;
                    //btnCat.MinWidth = 200;
                    btnCat.Height                     = 50;
                    btnCat.Tag                        = item;
                    btnCat.Click                     += BtnCat_Click1;
                    btnCat.TouchDown                 += BtnCat_Click1;
                    btnCat.HorizontalAlignment        = HorizontalAlignment.Stretch;
                    btnCat.HorizontalContentAlignment = HorizontalAlignment.Center;
                    btnCat.Margin                     = new Thickness(3);
                    btnCat.Background                 = Brushes.Black;

                    Categories.Add(btnCat);
                }
            }

            NotifyOfPropertyChange("Categories");
        }
Ejemplo n.º 2
0
    public async Task <IEnumerable <ShowDto> > GetAsync(int limit, string?term,
                                                        Guid?categoryId,
                                                        CancellationToken cancellationToken)
    {
        var showsQuery = _podcastDbContext.Shows.Include(show => show.Feed !.Categories)
                         .ThenInclude(x => x.Category)
                         .AsQueryable();

        if (!string.IsNullOrEmpty(term))
        {
            showsQuery = showsQuery.Where(show => show.Title.Contains(term));
        }

        if (categoryId is not null)
        {
            showsQuery = showsQuery.Where(show =>
                                          show.Feed !.Categories.Any(y => y.CategoryId == categoryId));
        }

        var shows = await showsQuery.OrderByDescending(show => show.Feed !.IsFeatured)
                    .ThenBy(x => x.Title)
                    .Take(limit)
                    .Select(x => new ShowDto(x))
                    .ToListAsync(cancellationToken);

        return(shows);
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Add new category in the categories combobox
 /// </summary>
 /// <param name="obj"></param>
 private void HandleNewCategory(CategoryAddedMessage obj)
 {
     if (Categories.Any())
     {
         Categories.Add(obj.NewCategory);
     }
 }
Ejemplo n.º 4
0
        internal void ComputeVisibility(SkillViewModel skillViewModel)
        {
            if (visibilityMode == VisibilityMode.Selected)
            {
                if (skillViewModel.HasCheckedAbility == false)
                {
                    skillViewModel.IsVisible = false;
                    return;
                }
            }
            else if (visibilityMode == VisibilityMode.Unselected)
            {
                if (skillViewModel.HasCheckedAbility)
                {
                    skillViewModel.IsVisible = false;
                    return;
                }
            }

            if (Categories.Any(x => x.Value))
            {
                if (IsMatchingByCategory(skillViewModel) == false)
                {
                    skillViewModel.IsVisible = false;
                    return;
                }
            }

            skillViewModel.ApplySearchText(SearchStatement.Create(searchTextPayload, GlobalData.Instance.Aliases), searchTextNumericModifier);
        }
Ejemplo n.º 5
0
        public void SeedData()
        {
            if (!Categories.Any())
            {
                var appliances = new Category()
                {
                    Name          = "Appliances",
                    Subcategories = new List <Category>()
                    {
                        new Category()
                        {
                            Name = "Microwaves"
                        }
                    }
                };
                Categories.Add(appliances);

                SaveChanges();
            }

            if (!Cities.Any())
            {
                Cities.AddRange(
                    new City {
                    Name = "New York"
                },
                    new City {
                    Name = "Seattle"
                },
                    new City {
                    Name = "San Francisco"
                });
                SaveChanges();
            }
        }
Ejemplo n.º 6
0
 public void AddCategory(Guid categoryId)
 {
     if (!Categories.Any(x => x.CategoryId == categoryId))
     {
         Categories.Add(new ArticleCategory(categoryId, Id));
     }
 }
        public void AddCategory()
        {
            var dialog = new AddUpdateCategoryDialog();

            dialog.Closing += (sender, args) =>
            {
                if (dialog.DataContext is AddUpdateCategoryViewModel vm)
                {
                    if (vm.Category != null && !Categories.Any(x => x == vm.Category))
                    {
                        Categories.Insert(0, vm.Category);
                    }
                    else
                    {
                        for (int i = 0; i < Categories.Count; i++)
                        {
                            if (Categories[i].Id == vm.Category.Id)
                            {
                                Categories[i] = vm.Category;
                                break;
                            }
                        }
                    }
                }
            };

            dialog.ShowDialogWindow(new AddUpdateCategoryViewModel(dialog), mWindow);
        }
Ejemplo n.º 8
0
        private async void Ajouter_LoadedWithClient(object sender, RoutedEventArgs e)
        {
            ClientName.Text          = LocalClient.Name;
            Phone.Text               = LocalClient.Phone;
            Remarks.Text             = LocalClient.Remarks;
            OrderedProducts          = LocalClient.Products;
            ProductsList.ItemsSource = OrderedProducts;
            DataHolder               = new DataHolder();
            await DataHolder.Init();

            foreach (var product in DataHolder.Products)
            {
                if (!Categories.Any(cat => cat.Category == product.Category))
                {
                    Categories.Add(new Product()
                    {
                        Category = product.Category,
                        Name     = product.Category,
                        Price    = 0,
                        Slicable = null
                    });
                }
            }
            ProductsMenu.ItemsSource = Categories;
        }
Ejemplo n.º 9
0
 internal Start UpdateEntity(Start start, DataContext dataContext)
 {
     start.Id           = Id;
     start.Name         = Name;
     start.PlannedStart = PlannedStart;
     start.RealStart    = RealStart;
     start.End          = End;
     start.DelayMarksAfterStartMinutes = DelayMarksAfterStartMinutes;
     #region update Categories list
     if (start.Categories == null)
     {
         start.Categories = new List <StartCategory>();
     }
     var toAdd    = Categories.Where(c => !start.Categories.Any(sc => sc.Category.Id == c.Id)).ToArray();
     var toRemove = start.Categories.Where(sc => !Categories.Any(c => c.Id == sc.Category.Id)).ToArray();
     foreach (var cat in toRemove)
     {
         start.Categories.Remove(cat);
     }
     foreach (var cat in toAdd)
     {
         start.Categories.Add(new StartCategory
         {
             Start    = start,
             Category = dataContext.RaceCategories.First(rc => rc.Id == cat.Id)
         });
     }
     #endregion
     return(start);
 }
Ejemplo n.º 10
0
        public void AddItem(IInventoryItem item)
        {
            if (!Categories.Any(c => c.Name.Equals(item.Category)))
            {
                throw new Exception(string.Format("The '{0}' category is not found in the database", item.Category));
            }

            InventoryHandler.AddItem(item);
        }
Ejemplo n.º 11
0
        public virtual void AddCategory(Guid categoryId)
        {
            if (Categories.Any(x => x.CategoryId == categoryId))
            {
                Categories.RemoveAll(x => x.CategoryId == categoryId);
            }

            Categories.Add(new ProductCategory(Id, categoryId));
        }
Ejemplo n.º 12
0
 string[] GetCategoriesWithFallback(IMod existingMod)
 {
     string[] categories;
     if (Categories == null || !Categories.Any())
     {
         var m = existingMod as Mod;
         if (m == null || m.Categories == null || !m.Categories.Any())
         {
             categories = new[] { Common.DefaultCategory }
         }
Ejemplo n.º 13
0
        protected override bool Matches(ITest test, bool parent)
        {
            var categories = test.Categories.ToList();

            if (categories == null || categories.Count == 0)
            {
                return(Categories.Count == 0);
            }

            return(MatchAll ? Categories.All(categories.Contains) : Categories.Any(categories.Contains));
        }
Ejemplo n.º 14
0
 public void ExtendCategories(IEnumerable <string> newCategories)
 {
     foreach (string category in newCategories)
     {
         if (!Categories.Any(c => c.Name.Equals(category)))
         {
             Categories.Add(new Category {
                 Name = category
             });
         }
     }
 }
Ejemplo n.º 15
0
 public bool CategoryCheck(object obj)
 {
     if (String.IsNullOrWhiteSpace(Name))
     {
         return(false);
     }
     if (Categories.Any(x => x.Name.Equals(this.Name)))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 16
0
        private void AssertNoDetachedReferences()
        {
            foreach (var payee in Payees)
            {
                if (payee.DefaultCategory != null)
                {
                    if (!Categories.Any(c => ReferenceEquals(c, payee.DefaultCategory)))
                    {
                        throw new MoneizException($"Database is not valid: category of payee '{payee}' is not valid");
                    }
                }
            }

            foreach (var transaction in Transactions)
            {
                if (transaction.Account != null)
                {
                    if (!Accounts.Any(c => ReferenceEquals(c, transaction.Account)))
                    {
                        throw new MoneizException($"Database is not valid: account of transaction '{transaction.Id}' is not valid");
                    }
                }

                if (transaction.Category != null)
                {
                    if (!Categories.Any(c => ReferenceEquals(c, transaction.Category)))
                    {
                        throw new MoneizException($"Database is not valid: category of transaction '{transaction.Id}' is not valid");
                    }
                }

                if (transaction.Payee != null)
                {
                    if (!Payees.Any(c => ReferenceEquals(c, transaction.Payee)))
                    {
                        throw new MoneizException($"Database is not valid: payee of transaction '{transaction.Id}' is not valid");
                    }
                }

                if (transaction.LinkedTransaction != null)
                {
                    if (!ReferenceEquals(transaction.LinkedTransaction.LinkedTransaction, transaction))
                    {
                        throw new MoneizException($"Database is not valid: linked transaction of transaction '{transaction.Id}' is not valid");
                    }

                    if (!Transactions.Any(c => ReferenceEquals(c, transaction.LinkedTransaction)))
                    {
                        throw new MoneizException($"Database is not valid: linked transaction of transaction '{transaction.Id}' is not valid");
                    }
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        ///     Gets a category with the specified non-case sensitive name or creates it if required.
        /// </summary>
        public static ReadoutCategory GetCategory(string name)
        {
            if (Categories.Any(c => c.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)))
            {
                return(Categories.Find(c => c.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)));
            }

            var category = new ReadoutCategory(name);

            Categories.Add(category);
            return(category);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Translates RankingGroup in xml
 /// </summary>
 /// <returns>map xml</returns>
 public XElement ToXml()
 {
     return(new XElement(
                "RankingGroup",
                new XAttribute("Id", Id),
                new XAttribute("Version", Version),
                Rules,
                Keywords.Any() ? new XElement("Keywords", Keywords.Select(_ => new XElement("Keyword", _))) : null,
                Categories.Any() ? new XElement("Categories", Categories.Select(_ => new XElement("Category", new XAttribute("Name", _)))) : null,
                NotFilteredId != null ? new XAttribute("NotFilteredId", NotFilteredId) : null,
                NotFilteredVersion != null ? new XAttribute("NotFilteredVersion", NotFilteredVersion) : null));
 }
Ejemplo n.º 19
0
        public void RefreshContext()
        {
            var results = DataFactory.GetAllCategory();

            if (Categories.Any())
            {
                Categories.RemoveRange(Categories);
                SaveChanges();
            }
            Categories.AddRangeAsync(results);
            SaveChanges();
        }
Ejemplo n.º 20
0
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement(nameof(DirectedGraph), Namespace);
            writer.WriteAttributeIfNotNull(nameof(Title), Title);
            writer.WriteAttributeIfNotNull(nameof(Background), Background);

            writer.WriteStartElement(nameof(Nodes));
            foreach (var node in Nodes)
            {
                node.WriteXml(writer);
            }
            writer.WriteEndElement();

            writer.WriteStartElement(nameof(Links));
            foreach (var link in Links)
            {
                link.WriteXml(writer);
            }
            writer.WriteEndElement();

            if (Categories.Any())
            {
                writer.WriteStartElement(nameof(Categories));
                foreach (var category in Categories)
                {
                    category.WriteXml(writer);
                }
                writer.WriteEndElement();
            }

            if (Styles.Any())
            {
                writer.WriteStartElement(nameof(Styles));
                foreach (var style in Styles)
                {
                    style.WriteXml(writer);
                }
                writer.WriteEndElement();
            }

            if (Properties.Any())
            {
                writer.WriteStartElement(nameof(Properties));
                foreach (var property in Properties)
                {
                    property.WriteXml(writer);
                }
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Ejemplo n.º 21
0
 public void AddCategory(string categoryName)
 {
     if (!Categories.Any(c => c.Name.Equals(categoryName)))
     {
         Categories.Add(new Category {
             Name = categoryName
         });
     }
     else
     {
         throw new Exception(string.Format("The '{0}' category already exists", categoryName));
     }
 }
Ejemplo n.º 22
0
 private void UpdateCategories()
 {
     Categories.Clear();
     for (int index = 0; index < _multiTiles.Count; index++)
     {
         var multiTile = _multiTiles[index];
         if (Categories.Any(c => c.FindTile(multiTile.Id) != null))
         {
             continue;
         }
         SelectTileforMultiTile(multiTile);
     }
 }
        private void PopulateCategoryDropDownList()
        {
            if (!Categories.Any())
            {
                LoadCategoryList();
            }

            ddlCategory.DataSource     = Categories;
            ddlCategory.DataValueField = "Id";
            ddlCategory.DataTextField  = "Name";
            ddlCategory.DataBind();
            ddlCategory.Items.Insert(0, new ListItem("--Select--", "0"));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Fill categories combobox if this wasn't already done
        /// </summary>
        private void AddCategories()
        {
            if (Categories.Any())
            {
                return;
            }

            // string.Empty for no category
            Categories.Add(string.Empty);
            foreach (var category in databaseRepository.GetDatabase().Categories.Select(x => x.Name))
            {
                Categories.Add(category);
            }
        }
        private void AddNewCategory(object parameter)
        {
            var categoryName = (string)parameter;

            if (Categories.Any(c => c.Name == categoryName))
            {
                return;
            }

            var category = new AppCategoryModel(categoryName);

            Categories.Add(category);
            IsNewCategoryOpen = false;
            NewCategoryName   = null;
        }
Ejemplo n.º 26
0
 public void AddCategory(Category category)
 {
     if (category == null)
     {
         return;
     }
     if (!Categories.Any(x => x.CategoryId == category.Id && x.PageId == this.Id))
     {
         Categories.Add(new PageCategory
         {
             Category = category,
             Page     = this
         });
     }
 }
Ejemplo n.º 27
0
 public void Delete()
 {
     if (Categories.Any())
     {
         throw new ArgumentOutOfRangeException("Category has descendants.");
     }
     if (Passwords.Any())
     {
         throw new ArgumentOutOfRangeException("Category has associated Passwords.");
     }
     if (Parent != null)
     {
         Parent.Categories.Remove(this);
         Context.DeleteCategory(this);
     }
 }
Ejemplo n.º 28
0
        public async Task CategoryAddedToPost(CategoryDto category)
        {
            try
            {
                CheckIfCategoryIsNull(category);

                if (Categories.Any(c => c.CategoryId == category.CategoryId))
                {
                    return;
                }
                Categories?.Add(category);
            }
            catch (Exception e)
            {
                await OnExecutableError.InvokeAsync(e);
            }
        }
Ejemplo n.º 29
0
        private void ClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            var dialogHost    = (DialogHost)sender;
            var dialogSession = dialogHost.CurrentSession;

            if (dialogSession.Content.GetType() == typeof(CreateEditCategoryDialog) &&
                eventArgs.Parameter is CreateEditCategoryViewModel dialogViewModel)
            {
                if (!dialogViewModel.IsValid())
                {
                    eventArgs.Cancel();
                }
                else if (Categories.Any(e =>
                                        string.Equals(e.Name, dialogViewModel.Name, StringComparison.OrdinalIgnoreCase) && !e.Id.Equals(dialogViewModel.Id)))
                {
                    dialogViewModel.ErrorMessage = "Category already exists.";
                    eventArgs.Cancel();
                }
            }
        }
Ejemplo n.º 30
0
        private async void Ajouter_Loaded(object sender, RoutedEventArgs e)
        {
            ProductsList.ItemsSource = OrderedProducts;
            DataHolder = new DataHolder();
            await DataHolder.Init();

            foreach (var product in DataHolder.Products)
            {
                if (!Categories.Any(cat => cat.Category == product.Category))
                {
                    Categories.Add(new Product()
                    {
                        Category = product.Category,
                        Name     = product.Category,
                        Price    = 0,
                        Slicable = null
                    });
                }
            }
            ProductsMenu.ItemsSource = Categories;
        }