public PoolModule(IPoolManager poolManager) { Get["/pool/{slug}/"] = _ => { var pool = poolManager.GetBySymbol(_.slug); if (pool != null) return View["pool", pool]; var error = new Error { Summary = "Pool not found", Details = string.Format("The request pool does not exist: {0}", _.slug) }; return View["error", error]; }; }
public PoolModule(IPoolManager poolManager, IStatistics statistics) { Get["/pool/{slug}/"] = _ => { ViewBag.LastUpdate = statistics.LastUpdate.ToString("HH:mm:ss tt zz"); // last statistics update. ViewBag.Pools = statistics.Pools; var pool = poolManager.GetBySymbol(_.slug); // find the requested pool. TODO: use IStatistics instead if (pool == null) // make sure queried pool exists. { ViewBag.Title = "Error"; ViewBag.Heading = "An error occured!"; return(View["error", new ErrorViewModel { Summary = "Pool not found", Details = string.Format("The requested pool does not exist: {0}", _.slug) }]); } ViewBag.Title = string.Format("{0} Pool", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Pool Details", pool.Config.Coin.Name); // return our view return(View["pool", new PoolModel { Pool = pool }]); }; Get["/pool/{slug}/workers"] = _ => { ViewBag.LastUpdate = statistics.LastUpdate.ToString("HH:mm:ss tt zz"); // last statistics update. ViewBag.Pools = statistics.Pools; var pool = statistics.Pools.GetBySymbol(_.slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { ViewBag.Title = "Error"; ViewBag.Heading = "An error occured!"; return(View["error", new ErrorViewModel { Summary = "Pool not found", Details = string.Format("The requested pool does not exist: {0}", _.slug) }]); } ViewBag.Title = string.Format("{0} Workers", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Workers", pool.Config.Coin.Name); // return our view return(View["workers", new WorkersModel { Workers = pool.Workers }]); }; Get["/pool/{slug}/round"] = _ => { ViewBag.LastUpdate = statistics.LastUpdate.ToString("HH:mm:ss tt zz"); // last statistics update. ViewBag.Pools = statistics.Pools; var pool = statistics.Pools.GetBySymbol(_.slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { ViewBag.Title = "Error"; ViewBag.Heading = "An error occured!"; return(View["error", new ErrorViewModel { Summary = "Pool not found", Details = string.Format("The requested pool does not exist: {0}", _.slug) }]); } ViewBag.Title = string.Format("{0} Current Round", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Current Round", pool.Config.Coin.Name); // return our view return(View["round", new CurrentRoundModel { Round = pool.Round, Shares = pool.CurrentRoundShares }]); }; }