protected override void Seed(SignalRDemoContext context) { using (var conn = new SqlConnection(context.Database.Connection.ConnectionString)) { conn.Open(); var command = conn.CreateCommand(); command.CommandText = "ALTER DATABASE [" + context.Database.Connection.Database + "] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE"; command.ExecuteNonQuery(); } context.Counters.AddOrUpdate(x => x.CounterId, new Counter() { CounterId = "175c0449", Name = "Let's count together", Value = 0 } ); context.Stocks.AddOrUpdate(x => x.Symbol, new Stock() { Symbol = "AAPL", Company = "Apple Inc.", LastUpdated = DateTime.Now, Price = 99.33, OldPrice = 99.33 }, new Stock() { Symbol = "EPAM", Company = "EPAM Systems Inc", LastUpdated = DateTime.Now, Price = 110.33, OldPrice = 110.33 }, new Stock() { Symbol = "GOOGL", Company = "Alphabet Inc", LastUpdated = DateTime.Now, Price = 832.71, OldPrice = 832.71 }, new Stock() { Symbol = "MSFT", Company = "Microsoft Corporation", LastUpdated = DateTime.Now, Price = 71.96, OldPrice = 71.96 } ); }
public IList <Subject> GetAllSubjects() { using (SignalRDemoContext context = new SignalRDemoContext()) { context.Configuration.AutoDetectChangesEnabled = false; context.Configuration.LazyLoadingEnabled = false; context.Configuration.ProxyCreationEnabled = false; List <Subject> retval = context.Subjects.AsNoTracking().ToList(); return(retval); } }
public Review AddReview(Review model) { Review toSave = new Review() { Subject = model.Subject, TwoWordReview = model.TwoWordReview }; using (SignalRDemoContext context = new SignalRDemoContext()) { context.Reviews.Add(toSave); context.SaveChanges(); } model.ReviewId = toSave.ReviewId; return(model); }
public UsersController(SignalRDemoContext dbContext, IMapper mapper) { this.dbContext = dbContext; this.mapper = mapper; }
public ProductOrchestrator(SignalRDemoContext dbContext) { _dbContext = dbContext; }
private StockTicker() { this.context = new SignalRDemoContext(); this.random = new Random(); this.timer = new Timer(this.Tick, null, 0, Timeout.Infinite); }
public List <PlayerJournalModel> Gets(string journalNumber) { var playerJournalModels = new List <PlayerJournalModel>(); try { using (var context = new SignalRDemoContext()) { var journalItems = context.JournalItem.Where(j => j.JournalId == Convert.ToInt32(journalNumber)).ToList(); foreach (var journalItem in journalItems) { var playerItem = context.PlayerDetail.Where(p => p.PlayerId == journalItem.PlayerId).FirstOrDefault(); var notificationItem = context.DummyAlertNotification.Where(n => n.UserId == journalItem.JournalId && n.PlayerId == journalItem.PlayerId && !n.IsDeleted).FirstOrDefault(); string alertPrice = "", isExpired = ""; alertPrice = (notificationItem != null && notificationItem.GreaterThan != null) ? "Over " + notificationItem.GreaterThan.ToString() : ""; alertPrice = (alertPrice == "" && notificationItem != null && notificationItem.SmallerThan != null) ? "Under " + notificationItem.SmallerThan.ToString() : alertPrice; if ((notificationItem != null && notificationItem.ExpiryDate != null)) { isExpired = (notificationItem.ExpiryDate < DateTime.Now) ? "True" : "False"; } // Create a new product PlayerJournalModel playerJournalModel = new PlayerJournalModel { JournalItemId = journalItem.JournalItemId.ToString(), JournalId = journalItem.JournalId.ToString(), PlayerId = journalItem.PlayerId.ToString(), BoughtPrice = journalItem.BoughtPrice.ToString("0,0", CultureInfo.InvariantCulture), Quantity = journalItem.Quantity.ToString(), Description = journalItem.Description.ToString(), SoldPrice = journalItem.SoldPrice.Value.ToString("0,0", CultureInfo.InvariantCulture), CreatedDate = journalItem.CreatedDate.ToString(), SoldDate = journalItem.SoldDate.ToString(), DeletedDate = journalItem.DeletedDate.ToString(), NotificationId = (notificationItem != null) ? notificationItem.NotificationId.ToString() : "", AlertPrice = alertPrice, IsExpired = isExpired, PlayerFullName = playerItem.PlayerFullName.ToString(), PlayerCardTypeId = ConvertPlayerCardType(playerItem.PlayerCardTypeId), FacePhotoUrl = playerItem.FacePhotoUrl.ToString(), BadgePhotoUrl = playerItem.BadgePhotoUrl.ToString(), NationPhotoUrl = playerItem.NationPhotoUrl.ToString(), Overall = playerItem.Overall.ToString(), CurrentPricePS4 = playerItem.CurrentPricePs4.Value.ToString("0,0", CultureInfo.InvariantCulture), Position = playerItem.Position.ToString(), LastUpdatedDate = CalculateTiem(playerItem.LastUpdatedDate.Value), TotalInvestment = (journalItem.Quantity * journalItem.BoughtPrice).ToString("0,0", CultureInfo.InvariantCulture), ProfitLossPerCard = ((int)(journalItem.SoldPrice - journalItem.BoughtPrice)).ToString("0,0", CultureInfo.InvariantCulture), TotalInvestmentPL = ((int)((journalItem.SoldPrice - journalItem.BoughtPrice) * journalItem.Quantity)).ToString("0,0", CultureInfo.InvariantCulture), OverallColor = ConvertPlayerCardTypeColor(playerItem.PlayerCardTypeId) }; playerJournalModels.Add(playerJournalModel); } } } catch (Exception e) { //retMessage = e.ToString(); } return(playerJournalModels); }
public CountersController(SignalRDemoContext dbContext, IMapper mapper, IHubContext <CountersHub> hubContext) { this.dbContext = dbContext; this.mapper = mapper; this.hubContext = hubContext; }
public CountersController(SignalRDemoContext dbContext, IMapper mapper) { this.dbContext = dbContext; this.mapper = mapper; this.hubContext = GlobalHost.ConnectionManager.GetHubContext <CountersHub>(); }