public void CommandAddTrainingAction(TrainingListStructure training)
        {
            var mainStack     = new StackLayout();
            var trainingLabel = new Label
            {
                Text           = LanguageUtils.Get(LanguageKeys.TrainingName),
                FontAttributes = FontAttributes.Bold,
                Margin         = new Thickness(0, 20, 0, 0)
            };

            mainStack.Children.Add(trainingLabel);
            var trainingPicker = new Picker
            {
                ItemsSource        = TrainingMasterService.GetTrainingMasterDataList(),
                ItemDisplayBinding = new Binding("TrainingName"),
                SelectedIndex      = 0
            };

            mainStack.Children.Add(trainingPicker);

            var trainingSetCountLabel = new Label
            {
                Text           = LanguageUtils.Get(LanguageKeys.SetCount),
                FontAttributes = FontAttributes.Bold,
                Margin         = new Thickness(0, 0, 0, 0)
            };

            mainStack.Children.Add(trainingSetCountLabel);

            var trainingSetCountEntry =
                new Entry {
                Text = training.TrainingSetCount.ToString(), Keyboard = Keyboard.Numeric
            };

            mainStack.Children.Add(trainingSetCountEntry);

            var trainingLoadStack = new StackLayout();


            trainingPicker.SelectedItem =
                ((List <TrainingMasterModel>)trainingPicker.ItemsSource).First(data => data.Id == training.TrainingId);

            foreach (var load in training.LoadContentList)
            {
                var loadModdel = LoadService.GetLoad(load.LoadId);

                var loadStack = new StackLayout();
                loadStack.Children.Add(new Label
                {
                    Text           = loadModdel.LoadName,
                    FontAttributes = FontAttributes.Bold,
                    Margin         = new Thickness(0, 0, 0, 0)
                });

                var subLoadStack = new StackLayout {
                    Orientation = StackOrientation.Horizontal
                };
                subLoadStack.Children.Add(new Entry
                {
                    Text         = load.Nums.ToString(),
                    Keyboard     = Keyboard.Numeric,
                    WidthRequest = 145
                });
                var loadUnitPick = new Picker
                {
                    ItemsSource        = LoadUnitService.GetLoadUnitList(load.LoadId),
                    ItemDisplayBinding = new Binding("UnitName"),
                    SelectedIndex      = 0,
                    WidthRequest       = 145
                };
                loadUnitPick.SelectedItem =
                    ((List <LoadUnitModel>)loadUnitPick.ItemsSource).First(data => data.Id == load.LoadUnitId);

                subLoadStack.Children.Add(loadUnitPick);

                loadStack.Children.Add(subLoadStack);
                trainingLoadStack.Children.Add(loadStack);
            }

            trainingPicker.SelectedIndexChanged += (sender, args) =>
            {
                trainingLoadStack.Children.Clear();
                var loadList =
                    JsonConvert.DeserializeObject <LoadStructure>(((TrainingMasterModel)trainingPicker.SelectedItem)
                                                                  .Load);
                foreach (var load in loadList.LoadList)
                {
                    var loadStack = new StackLayout();
                    loadStack.Children.Add(new Label
                    {
                        Text           = load.LoadName,
                        FontAttributes = FontAttributes.Bold,
                        Margin         = new Thickness(0, 0, 0, 0)
                    });

                    var subLoadStack = new StackLayout {
                        Orientation = StackOrientation.Horizontal
                    };
                    subLoadStack.Children.Add(new Entry {
                        Keyboard = Keyboard.Numeric, WidthRequest = 145
                    });
                    subLoadStack.Children.Add(new Picker
                    {
                        ItemsSource        = LoadUnitService.GetLoadUnitList(load.Id),
                        ItemDisplayBinding = new Binding("UnitName"),
                        SelectedIndex      = 0,
                        WidthRequest       = 145
                    });
                    loadStack.Children.Add(subLoadStack);
                    trainingLoadStack.Children.Add(loadStack);
                }
            };

            mainStack.Children.Add(trainingLoadStack);
            TrainingStack.Children.Add(mainStack);
        }
Exemple #2
0
        public static TrainingScheduleSViewtructure CreateTrainingScheduleSViewtructure(WeekEnum week)
        {
            var model = TrainingScheduleService.GetTrainingSchedule((int)week);

            if (model == null)
            {
                var empty = new TrainingScheduleSViewtructure
                {
                    Week     = (int)week,
                    WeekName = week.ToString(),
                    Off      = false
                };
                return(empty);
            }

            var trainingScheduleStructure =
                JsonConvert.DeserializeObject <TrainingScheduleStructure>(model.TrainingMenu);

            var trainingScheduleViewStructure = new TrainingScheduleSViewtructure
            {
                Week     = (int)week,
                WeekName = week.ToString(),
                Off      = trainingScheduleStructure.Off
            };

            var trainingListViewStructureList = new List <TrainingListViewStructure>();

            int count = 1;

            foreach (var training in trainingScheduleStructure.TrainingContentList)
            {
                var trainingListViewStructure = new TrainingListViewStructure
                {
                    TrainingId       = training.TrainingId,
                    TrainingNo       = count,
                    TrainingName     = TrainingMasterService.GetTrainingMasterData(training.TrainingId).TrainingName,
                    TrainingSetCount = training.TrainingSetCount
                };
                var loadContentViewStructureList = new List <LoadContentViewStructure>();

                foreach (var load in training.LoadContentList)
                {
                    var loadContentViewStructure = new LoadContentViewStructure
                    {
                        LoadId       = load.LoadId,
                        LoadName     = LoadService.GetLoad(load.LoadId).LoadName,
                        Nums         = load.Nums.ToString(),
                        LoadUnitId   = load.LoadUnitId,
                        LoadUnitName = LoadUnitService.GetLoadUnit(load.LoadUnitId).UnitName
                    };
                    loadContentViewStructureList.Add(loadContentViewStructure);
                }

                trainingListViewStructure.LoadContentList = loadContentViewStructureList;

                trainingListViewStructureList.Add(trainingListViewStructure);
                count++;
            }

            trainingScheduleViewStructure.TrainingContentList = trainingListViewStructureList;

            return(trainingScheduleViewStructure);
        }