Ejemplo n.º 1
0
 public CyptoItem GetObjCyptoItem(long id)
 {
     try {
         CyptoItem ObjCyptoItem = db.CyptoItems.Find(id);
         return(ObjCyptoItem);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
 public async Task <int> UpdateCypto(CyptoItem ObjCyptoItem)
 {
     try
     {
         db.Entry(ObjCyptoItem).State = EntityState.Modified;
         return(await db.SaveChangesAsync());
     }
     catch (Exception ex)
     {
         this.AddToExceptionLog("UpdateCypto", "Ctrl.CyptoItem", ex.ToString());
         return(0);
     }
 }
Ejemplo n.º 3
0
        public async Task <int> UpdateCyptoItem(CyptoItem ObjCyptoItem)
        {
            try
            {
                db.Entry(ObjCyptoItem).State = EntityState.Modified;
                int rs = await db.SaveChangesAsync();

                return((int)EnumCore.Result.action_true);
            }
            catch (Exception ex)
            {
                return((int)EnumCore.Result.action_false);
            }
        }
Ejemplo n.º 4
0
        public async Task <int> CreateCyptoItem(CyptoItem ObjCyptoItem)
        {
            try
            {
                db.CyptoItems.Add(ObjCyptoItem);
                await db.SaveChangesAsync();

                return((int)EnumCore.Result.action_true);
            }
            catch (Exception e)
            {
                return((int)EnumCore.Result.action_false);
            }
        }
        public async Task <ActionResult> EditCypto(CyptoItemViewModel model)
        {
            if (ModelState.IsValid)
            {
                CyptoItem ObjCyptoItem = cms_db.GetObjCyptoItem(model.id);
                ObjCyptoItem.is_active    = model.is_active;
                ObjCyptoItem.allow_update = model.allow_update;

                int rs = await cms_db.UpdateCypto(ObjCyptoItem);

                return(RedirectToAction("EditCypto", new { id = model.id }));
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> GetAndUpcateTableCyptoItem()
        {
            CoinMarketDataRespon coinmaketresult = await _client.GetListCyptoItemAsync();

            foreach (CyproEntity Item in coinmaketresult.data)
            {
                CyptoItem objCyptoItem = new CyptoItem();
                objCyptoItem.id     = Item.id;
                objCyptoItem.name   = Item.name;
                objCyptoItem.symbol = Item.symbol;
                objCyptoItem.slug   = Item.slug;
                if (Item.is_active == 1)
                {
                    objCyptoItem.is_active = true;
                }
                else
                {
                    objCyptoItem.is_active = false;
                }

                try
                {
                    objCyptoItem.first_historical_data = DateTime.Parse(Item.first_historical_data);
                }
                catch
                {
                    objCyptoItem.first_historical_data = DateTime.Now;
                }

                try
                {
                    objCyptoItem.last_historical_data = DateTime.Parse(Item.last_historical_data);
                }
                catch
                {
                    objCyptoItem.last_historical_data = DateTime.Now;
                }


                await cms_db.CreateCyptoItem(objCyptoItem);
            }
            return(View());
        }
Ejemplo n.º 7
0
 public CyptoItemViewModel(CyptoItem model)
 {
     _MainObj = model;
 }
Ejemplo n.º 8
0
 public CyptoItemViewModel()
 {
     _MainObj = new CyptoItem();
 }