Exemplo n.º 1
0
        public async Task <bool> Update(PreciousMetal model)
        {
            this.logger.LogWarning("Update Starts");
            bool result  = false;
            bool isEmpty = await isEmptyTable();

            if (isEmpty)
            {
                Create();
            }

            PreciousMetal temp = this.datacontext.PreciousMetals.Select(s => s).FirstOrDefault();

            if (temp != null)
            {
                temp.Gold       = model.Gold;
                temp.Silver     = model.Silver;
                temp.Platinum   = model.Platinum;
                temp.Palladium  = model.Palladium;
                temp.LastUpdate = DateTime.Now;
                this.datacontext.PreciousMetals.Update(temp);
                this.datacontext.SaveChanges();
                result = true;
            }
            this.logger.LogWarning("Update Stops");
            return(result);
        }
Exemplo n.º 2
0
        private void Create()
        {
            this.logger.LogWarning("Create Starts");
            PreciousMetal model = new PreciousMetal();

            this.datacontext.PreciousMetals.Add(model);
            this.logger.LogWarning("Create Stops");
        }
Exemplo n.º 3
0
        public async Task <PreciousMetal> Read()
        {
            this.logger.LogWarning("Read Starts");
            PreciousMetal metal = await this.datacontext.PreciousMetals.Select(s => s).OrderByDescending(o => o.LastUpdate).FirstOrDefaultAsync();

            this.logger.LogWarning("metal is NULL ? = " + (metal == null));
            this.logger.LogWarning("Read Stops");
            return(metal);
        }
Exemplo n.º 4
0
 public void ClosePreciousMetal()
 {
     if (PM != null)
     {
         PM.gameObject.SetActive(false);
         GameObject.Destroy(PM.gameObject);
         PM = null;
     }
 }
Exemplo n.º 5
0
    public void LoadPreciousMetal(string assetBundleName, string prefabName)
    {
        ClosePreciousMetal();
        GameObject o = ResourcesManager.Instance.LoadAssetBundle(assetBundleName, prefabName);

        o.name = "PreciousMetal";
        o.SetActive(true);
        PM = o.GetComponent <PreciousMetal>();

        GameObject homePage = UIManager.Instance.ShowWindowUI(WindowUIType.PMHomePage);

        homePage.GetComponent <HomePage>().LoadPreciousMetalUI();
    }