示例#1
0
        /// <summary>
        /// トレーニングマスタ登録
        /// </summary>
        /// <param name="trainingName"></param>
        /// <param name="load"></param>
        /// <param name="part"></param>
        /// <returns></returns>
        public static bool RegistTrainingMaster(string trainingName, string load, string part)
        {
            var model = new TrainingMasterModel
            {
                TrainingName = trainingName,
                Load         = load,
                Part         = part,
                RegistedDate = DateTime.Now
            };

            using (var db = new SQLiteConnection(DbConst.DbPath))
            {
                var result = db.Insert(model);
                if (result == DbConst.Failed)
                {
                    return(false);
                }
                db.Commit();
                return(true);
            }
        }
示例#2
0
        /// <summary>
        /// トレーニングマスタ更新
        /// </summary>
        /// <param name="id"></param>
        /// <param name="trainingName"></param>
        /// <param name="load"></param>
        /// <param name="part"></param>
        /// <returns></returns>
        public static bool UpdateTrainingMaster(int id, string trainingName, string load, string part)
        {
            var model = new TrainingMasterModel
            {
                Id           = id,
                TrainingName = trainingName,
                Load         = load,
                Part         = part,
                RegistedDate = DateTime.Now
            };
            var s = JsonConvert.SerializeObject(model);

            using (var db = new SQLiteConnection(DbConst.DbPath))
            {
                var result = db.Update(model);
                if (result == DbConst.Failed)
                {
                    return(false);
                }
                db.Commit();
                return(true);
            }
        }
        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;
        }