Example #1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Entities.BusinessEntity.Select().ForEach(x => BusinessEntity.Items.Add(Entities.BusinessEntity.ToTextBlock(x)));
     Entities.Activity.Select().ForEach(x => Activity.Items.Add(Entities.Activity.ToTextBlock(x)));
     Entities.ActivityDirection.Select().ForEach(x => ActivityDirection.Items.Add(Entities.ActivityDirection.ToTextBlock(x)));
     Entities.Region.Select().ForEach(x => Region.Items.Add(Entities.Region.ToTextBlock(x)));
     if (Dealer == null)
     {
         Dealer = new Dealer();
         BusinessEntity.SelectItem();
         Activity.SelectItem();
         ActivityDirection.SelectItem();
         Region.SelectItem();
         Title = "Добавление дилера";
     }
     else
     {
         BusinessEntity.SelectItem(BusinessEntity.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == Dealer.BusinessEntityId));
         _Name.Text = Dealer.Name;
         Activity.SelectItem(Activity.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == Dealer.ActivityId));
         ActivityDirection.SelectItem(ActivityDirection.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == Dealer.ActivityDirectionId));
         Rating.SelectItem(selectedIndex: 5 - (int)Dealer.Rating);
         Relevance.SelectItem(selectedIndex: Dealer.IsRelevant ? 0 : 1);
         Region.SelectItem(Region.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == Dealer.RegionId));
         City.Text   = Dealer.City;
         Street.Text = Dealer.Street;
         House.Text  = Dealer.House;
         Block.Text  = Dealer.Block;
         Room.Text   = Dealer.Room;
         UpdateContacts();
         Contacts.SelectItem();
         Note.Text       = Dealer.Note;
         Conditions.Text = Dealer.Conditions;
         UpdateEvents();
         Events.SelectItem(selectedIndex: 1);
         Title = "Правка дилера";
     }
 }