コード例 #1
0
        void AddExecute()
        {
            Int64 startTicks = Log.VIEWMODEL("(ToyDetailViewModel) Enter", Common.LOG_CATEGORY);

            var wrapper = new ToyWrapper(new Domain.Toy());

            wrapper.PropertyChanged += Wrapper_PropertyChanged;

            _ToyDataService.Add(wrapper.Model);
            Toys.Add(wrapper);

            wrapper.Name = "";  // Trigger the validation

            Log.VIEWMODEL("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
コード例 #2
0
        public void AddToy()
        {
repeate:
            Console.WriteLine("--->> ADD Toys <<---");
            Console.WriteLine("-->Select id from given ToyTypes<--");
            Console.WriteLine("Id\t ToyType");
            foreach (ToyType toyType in toyTypeDomain.GetToyType())
            {
                Console.WriteLine($"{toyType.ToyTypeId}\t  {toyType.ToyTypeName}");
            }
            Console.WriteLine("-->Select id from given Plant List<--");
            Console.WriteLine("Id\tPlantName\tPlantAddress");
            foreach (Plant plant in plantDomain.GetAllPlant())
            {
                Console.WriteLine($"{plant.PlantId}\t  {plant.PlantName}\t\t{plant.PlantAddress} ");
            }


            Console.WriteLine("Enter Toy Price: ");
            toy.ToyPrice = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Enter ToyTypeId:");
            toy.ToyTypeId = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Enter PlantId:");
            toy.PlantId = Int32.Parse(Console.ReadLine());

            if (toy.PlantId != 0 && toy.ToyPrice != 0 && toy.ToyTypeId != 0)
            {
                try
                {
                    Toys.Add(toy);
                    SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            else
            {
                Console.WriteLine(" !!Enter all required fields!! ");
                goto repeate;
            }
        }
コード例 #3
0
        private void GenerateDemoData()
        {
            ObservableCollection <ItemVm> lego = new ObservableCollection <ItemVm>();

            lego.Add(new ItemVm("Lego 2", new BitmapImage(new Uri("Images/lego2.jpg", UriKind.Relative)), "5+"));
            lego.Add(new ItemVm("Lego 3", new BitmapImage(new Uri("Images/lego3.jpg", UriKind.Relative)), "8-10"));
            lego.Add(new ItemVm("Lego 4", new BitmapImage(new Uri("Images/lego4.jpg", UriKind.Relative)), "8+"));

            ObservableCollection <ItemVm> playmobil = new ObservableCollection <ItemVm>();

            playmobil.Add(new ItemVm("Playmobil 2", new BitmapImage(new Uri("Images/playmobil2.jpg", UriKind.Relative)), "5+"));
            playmobil.Add(new ItemVm("Playmobil 2", new BitmapImage(new Uri("Images/playmobil2.jpg", UriKind.Relative)), "5+"));
            playmobil.Add(new ItemVm("Playmobil 2", new BitmapImage(new Uri("Images/playmobil2.jpg", UriKind.Relative)), "5+"));
            playmobil.Add(new ItemVm("Playmobil 3", new BitmapImage(new Uri("Images/playmobil3.jpg", UriKind.Relative)), "10+"));
            playmobil.Add(new ItemVm("Playmobil 3", new BitmapImage(new Uri("Images/playmobil3.jpg", UriKind.Relative)), "10+"));
            playmobil.Add(new ItemVm("Playmobil 3", new BitmapImage(new Uri("Images/playmobil3.jpg", UriKind.Relative)), "10+"));

            Toys.Add(new ToyVm("MY Lego", new BitmapImage((new Uri("Images/lego1.jpg", UriKind.Relative))), lego));
            Toys.Add(new ToyVm("MY Playmobil", new BitmapImage((new Uri("Images/playmobil1.jpg", UriKind.Relative))), playmobil));
        }
コード例 #4
0
        private async Task LoadToysLookupAsync()
        {
            Int64 startTicks = Log.VIEWMODEL("(CatDetailViewModel) Enter", Common.LOG_CATEGORY);

            Toys.Clear();

            //ProgrammingLanguages.Add(new NullLookupItem());
            Toys.Add(new NullLookupItem {
                DisplayMember = " - "
            });

            var lookup = await _ToyLookupDataService
                         .GetToyLookupAsync();

            foreach (var lookupItem in lookup)
            {
                Toys.Add(lookupItem);
            }

            Log.VIEWMODEL("(CatDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
コード例 #5
0
        // private async void OpenDetailView(OpenDetailViewEventArgs args)
        // {
        // Int64 startTicks = Log.EVENT("(ToyDetailViewModel) Enter", Common.LOG_CATEGORY);

        // await LoadAsync(args.Id);

        // Log.EVENT("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        // }

        #endregion

        #region Public Methods

        public override async Task LoadAsync(int id)
        {
            Int64 startTicks = Log.VIEWMODEL("(ToyDetailViewModel) Enter Id:({id})", Common.LOG_CATEGORY);

            Id = id;

            foreach (var wrapper in Toys)
            {
                wrapper.PropertyChanged -= Wrapper_PropertyChanged;
            }

            Toys.Clear();

            var items = await _ToyDataService.AllAsync();

            foreach (var model in items)
            {
                var wrapper = new ToyWrapper(model);
                wrapper.PropertyChanged += Wrapper_PropertyChanged;
                Toys.Add(wrapper);
            }

            Log.VIEWMODEL("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
コード例 #6
0
 public ToyBox(string Name)
 {
     Toys.Add(Name);
 }