Пример #1
0
        public Model.ModelLifeCounter UpdateLifeCounter(Model.ModelLifeCounter data)
        {
            conn.CreateCommand("Select * From ModelLifeCounter where Id = " + data.Id.ToString());

            var model = conn.Query <Model.ModelLifeCounter>("Select * From ModelLifeCounter where Id = " + data.Id.ToString()).SingleOrDefault();

            model.Deleted = false;
            model.CommanderDamageCounter = data.CommanderDamageCounter;
            model.Life = data.Life;
            model.PoisonDamageCounter = data.PoisonDamageCounter;
            model.Updated             = true;
            model.UpdateDate          = DateTime.Now;
            model.User = "******";
            conn.Update(model);
            conn.Commit();

            Model.ModelLifeCounter updatedModel = new Model.ModelLifeCounter();
            updatedModel.Id       = model.Id;
            updatedModel.Inserted = model.Inserted;
            updatedModel.CommanderDamageCounter = model.CommanderDamageCounter;
            updatedModel.CreateDate             = model.CreateDate;
            updatedModel.Deleted             = model.Deleted;
            updatedModel.Life                = model.Life;
            updatedModel.PoisonDamageCounter = model.PoisonDamageCounter;
            updatedModel.Updated             = model.Updated;
            updatedModel.UpdateDate          = model.UpdateDate;
            updatedModel.User                = model.User;
            return(updatedModel);
        }
Пример #2
0
        private Model.ModelLifeCounter Translate(ViewModel.LifeCounter dataModel)
        {
            Model.ModelLifeCounter model = new Model.ModelLifeCounter();
            model.CommanderDamageCounter = dataModel.CommanderDamageCounter;
            model.CreateDate             = dataModel.CreateDate;
            model.Deleted             = dataModel.Deleted;
            model.Id                  = dataModel.Id;
            model.Inserted            = dataModel.Inserted;
            model.Life                = dataModel.Life;
            model.PoisonDamageCounter = dataModel.PoisonDamageCounter;
            model.Updated             = dataModel.Updated;
            model.UpdateDate          = dataModel.UpdateDate;
            model.User                = dataModel.User;

            return(model);
        }
Пример #3
0
        private ViewModel.LifeCounter Translate(Model.ModelLifeCounter model)
        {
            ViewModel.LifeCounter returnView = new ViewModel.LifeCounter();
            returnView.CommanderDamageCounter = model.CommanderDamageCounter;
            returnView.CreateDate             = model.CreateDate;
            returnView.Deleted             = model.Deleted;
            returnView.Id                  = model.Id;
            returnView.Inserted            = model.Inserted;
            returnView.Life                = model.Life;
            returnView.PoisonDamageCounter = model.PoisonDamageCounter;
            returnView.Updated             = model.Updated;
            returnView.UpdateDate          = model.UpdateDate;
            returnView.User                = model.User;

            return(returnView);
        }
Пример #4
0
        public Model.ModelLifeCounter AddLifeCounter(Model.ModelLifeCounter data)
        {
            Model.ModelLifeCounter addModel = new Model.ModelLifeCounter();
            addModel.CommanderDamageCounter = data.CommanderDamageCounter;
            addModel.CreateDate             = DateTime.Now;
            addModel.Inserted            = true;
            addModel.Life                = data.Life;
            addModel.PoisonDamageCounter = data.PoisonDamageCounter;
            addModel.Updated             = false;
            addModel.UpdateDate          = DateTime.Now;
            addModel.User                = "******";
            conn.Insert(addModel);
            conn.Commit();

            data.Id = addModel.Id;
            return(data);
        }
Пример #5
0
        public Model.ModelLifeCounter GetLatestEntry()
        {
            var model = conn.Query <Model.ModelLifeCounter>("Select * From ModelLifeCounter").OrderByDescending(x => x.CreateDate).FirstOrDefault();

            Model.ModelLifeCounter updatedModel = new Model.ModelLifeCounter();
            if (model != null)
            {
                updatedModel.Id       = model.Id;
                updatedModel.Inserted = model.Inserted;
                updatedModel.CommanderDamageCounter = model.CommanderDamageCounter;
                updatedModel.CreateDate             = model.CreateDate;
                updatedModel.Deleted             = model.Deleted;
                updatedModel.Life                = model.Life;
                updatedModel.PoisonDamageCounter = model.PoisonDamageCounter;
                updatedModel.Updated             = model.Updated;
                updatedModel.UpdateDate          = model.UpdateDate;
                updatedModel.User                = model.User;
            }

            return(updatedModel);
        }
Пример #6
0
        private void SetupTabs(SqliteConnection conn, Model.ModelLifeCounter model)
        {
            ActionBar.Tab tab = ActionBar.NewTab();
            tab.SetText("Life");

            tab.TabSelected += (sender, args) =>
            {
                conn.UpdateLifeCounter(Translate(mainActivityModel));
                SetContentView(Resource.Layout.LifeCounter);
                model = conn.GetLatestEntry();
                SetupLifeMainView(Translate(model));
            };
            ActionBar.AddTab(tab);

            tab = ActionBar.NewTab();
            tab.SetText("Poison");

            tab.TabSelected += (sender, args) =>
            {
                conn.UpdateLifeCounter(Translate(mainActivityModel));
                SetContentView(Resource.Layout.layPoison);
                model = conn.GetLatestEntry();
                SetupLifeMainView(Translate(model));
            };
            ActionBar.AddTab(tab);

            tab = ActionBar.NewTab();

            tab.SetText("Commander");

            tab.TabSelected += (sender, args) =>
            {
                conn.UpdateLifeCounter(Translate(mainActivityModel));
                SetContentView(Resource.Layout.layCommander);
                model = conn.GetLatestEntry();
                SetupLifeMainView(Translate(model));
            };
            ActionBar.AddTab(tab);
        }