public TrainingMasterViewModel(StackLayout partStack, StackLayout loadStack, int id) { PartStack = partStack; LoadStack = loadStack; _targetTrainingMasterModel = TrainingMasterService.GetTrainingMasterData(id); InitCommands(); var partStructureList = JsonConvert.DeserializeObject <List <PartStructure> >(_targetTrainingMasterModel.Part); var loadStructure = JsonConvert.DeserializeObject <LoadStructure>(_targetTrainingMasterModel.Load); foreach (var data in partStructureList) { CommandAddPartAction(data.Part.Id, data.SubPart.Id); } foreach (var data in loadStructure.LoadList) { CommandAddLoadAction(data.Id); } TrainingName = _targetTrainingMasterModel.TrainingName; }
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); }