예제 #1
0
        /*----------------------------------------------------------------------------------------------------------------------------------------*/
        //
        // Constractor
        //
        /*----------------------------------------------------------------------------------------------------------------------------------------*/
        #region Constractor

        public TrainingViewModel()
        {
            InitCommands();
            _pageOpenDateTime = DateTime.Now;
            var week = (int)DateTime.Now.DayOfWeek;

            _timer       = new Timer(TimeSpan.FromSeconds(1), CountDown);
            TotalSeconds = _totalSeconds;
            _trainingScheduleSViewtructure = ViewModelCommonUtil.CreateTrainingScheduleSViewtructure((WeekEnum)week);
            TrainingMenu = _trainingScheduleSViewtructure.ToString();
            Items        = _trainingScheduleSViewtructure.TrainingContentList;
            WeekLabel    = _trainingScheduleSViewtructure.WeekName;
            TrainingStartButtonVisible = true;
        }
예제 #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);
        }