示例#1
0
        public void Update()
        {
            try
            {
                WealthDataContext oDc = new WealthDataContext();

                tblCrypto stock = oDc.tblCryptos.FirstOrDefault(p => p.Id == this.Id);

                if (stock != null)
                {
                    stock.Symbol = this.Ticker;
                    decimal.TryParse(GetPrice(this.Ticker).ToString(), out decimal g);
                    stock.CurrentPrice = g;

                    stock.UserId = this.UserId;
                    oDc.SubmitChanges();
                }
                else
                {
                    throw new Exception("Row not found. (Id : " + this.Id + ")");
                }
            }
            catch (Exception ex)
            {
                CErrorLog err = new CErrorLog();
                err.LogError(ex.Message);
                throw ex;
            }
        }
示例#2
0
        public void LoadById(Guid id)
        {
            WealthDataContext oDc   = new WealthDataContext();
            tblCrypto         stock = oDc.tblCryptos.FirstOrDefault(p => p.Id == Id);

            if (stock != null)
            {
                this.Id = stock.Id;
            }
            this.Price = GetPrice(this.Ticker);
            if (stock != null)
            {
                this.Ticker = stock.Symbol;
            }
        }
示例#3
0
        public void Insert()
        {
            try
            {
                WealthDataContext oDc = new WealthDataContext();

                var results = (from s in oDc.tblCryptos
                               join u in oDc.tblUsers on s.UserId equals u.Id
                               where u.Id == CLogin.UserLoggedIn & s.Id == this.Id

                               select new
                {
                    s.Id,
                    custId = s.UserId,
                    s.Symbol,
                    s.CurrentPrice,
                }).ToList();

                if (results != null)
                {
                    //WealthDataContext oDc = new WealthDataContext();

                    tblCrypto stock = new tblCrypto();

                    stock.Id     = Guid.NewGuid();
                    stock.UserId = CLogin.UserLoggedIn;
                    stock.Symbol = this.Ticker;

                    decimal.TryParse(GetPrice(this.Ticker).ToString(), out decimal g);
                    stock.CurrentPrice = g;


                    oDc.tblCryptos.InsertOnSubmit(stock);
                    oDc.SubmitChanges();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                CErrorLog err = new CErrorLog();
                err.LogError(ex.Message);
                throw ex;
            }
        }
示例#4
0
        public void Delete()
        {
            try
            {
                WealthDataContext oDc   = new WealthDataContext();
                tblCrypto         stock = oDc.tblCryptos.FirstOrDefault(p => p.Id == this.Id);

                if (stock != null)
                {
                    oDc.tblCryptos.DeleteOnSubmit(stock);
                    oDc.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                CErrorLog err = new CErrorLog();
                err.LogError(ex.Message);
                throw ex;
            }
        }
示例#5
0
        public void LoadById()
        {
            try
            {
                WealthDataContext oDc   = new WealthDataContext();
                tblCrypto         stock = oDc.tblCryptos.FirstOrDefault(p => p.Id == this.Id);

                if (stock != null)
                {
                    this.Id     = stock.Id;
                    this.Ticker = stock.Symbol;
                    this.Price  = GetPrice(this.Ticker);
                    //this.UserId = stock.UserId;
                }
            }
            catch (Exception ex)
            {
                CErrorLog err = new CErrorLog();
                err.LogError(ex.Message);
                throw ex;
            }
        }