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; } }
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; } }
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; } }
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; } }
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; } }