public static Blocks ModelToEnity(this BlocksModel model, bool virtualActive = false) { Blocks entity = new Blocks() { BlockName = model.BlockName, Id = model.Id, IsActive = model.IsActive }; if (virtualActive) { entity.BlockFloors = model.BlockFloors; } return(entity); }
public ActionResult BlockInsert(BlocksModel blocksModel, int[] floorsList) { Blocks block = blocksModel.ModelToEnity(true); block.IsActive = true; _serviceBlocks.Insert(block); for (int i = 0; i < floorsList.Length; i++) { BlockFloors blockFloors = new BlockFloors(); blockFloors.BlockId = block.Id; blockFloors.FloorId = floorsList[i]; _serviceBlockFloors.Insert(blockFloors); } return(RedirectToAction("BlockList")); }
public static BlocksModel EntityToModel(this Blocks entity, bool virtualActive = false) { try { BlocksModel model = new BlocksModel() { BlockName = entity.BlockName, IsActive = entity.IsActive, Id = entity.Id }; if (virtualActive) { model.BlockFloors = entity.BlockFloors; } return(model); } catch (Exception) { return(new BlocksModel()); } }
public void Test() { var doc = Application.DocumentManager.MdiActiveDocument; if (doc == null) { return; } var db = doc.Database; var blocks = new BlocksModel(db); var win = new BlocksView(blocks); try { if (Application.ShowModalWindow(win) == true) { var selBlocks = blocks.Selected; if (selBlocks != null) { using (var t = db.TransactionManager.StartTransaction()) { var cs = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord; foreach (var item in selBlocks) { var blRef = new BlockReference(Point3d.Origin, item.Id); cs.AppendEntity(blRef); t.AddNewlyCreatedDBObject(blRef, true); } t.Commit(); } } } } catch (System.Exception ex) { doc.Editor.WriteMessage($"\n{ex}"); } }
public IndexModule(IPoolManager poolManager) { Get["/"] = _ => { var pool = poolManager.Get(slug); // find the requested pool. if (pool == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } ViewBag.Title = string.Format("{0} Mining Pool", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Mining Pool", pool.Config.Coin.Name); // return our view return(View["pool", new PoolModel { Pool = pool }]); }; Get["/workers"] = _ => { var pool = poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } ViewBag.Header = string.Format("{0} Workers", pool.Config.Coin.Name); // return our view return(View["workers", new WorkersModel { Workers = pool.MinerManager.Miners }]); }; Get["/round"] = _ => { var pool = poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } ViewBag.Header = string.Format("{0} Current Round", pool.Config.Coin.Name); // return our view return(View["round", new RoundModel { Round = pool.NetworkInfo.Round, Shares = pool.RoundShares }]); }; Get["/blocks/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } int page; if (!Int32.TryParse(_.page, out page)) { page = 1; } var paginationQuery = new PaginationQuery(page); var blocks = pool.BlockRepository.GetBlocks(paginationQuery); if (blocks.Count == 0) { return(View["error", new ErrorViewModel { Details = "No more blocks exist" }]); } var model = new BlocksModel { Blocks = blocks, Coin = pool.Config.Coin, Filter = BlockFilter.All, PaginationQuery = paginationQuery }; return(View["blocks", model]); }; Get["/blocks/paid/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } int page; if (!Int32.TryParse(_.page, out page)) { page = 1; } var paginationQuery = new PaginationQuery(page); var blocks = pool.BlockRepository.GetPaidBlocks(paginationQuery); if (blocks.Count == 0) { return(View["error", new ErrorViewModel { Details = "No more blocks exist" }]); } var model = new BlocksModel { Blocks = blocks, Coin = pool.Config.Coin, Filter = BlockFilter.PaidOnly, PaginationQuery = paginationQuery }; return(View["blocks", model]); }; Get["/block/{height:int}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } var block = pool.BlockRepository.Get((uint)_.height); if (block == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested block does not exist: {0}", _.height) }]); } var model = new BlockModel { Block = block, Coin = pool.Config.Coin, Payments = pool.PaymentRepository.GetPaymentDetailsForBlock((uint)_.height) }; ViewBag.Header = string.Format("Block {0}", block.Height); ViewBag.SubHeader = string.Format("{0} block", pool.Config.Coin.Name); return(View["block", model]); }; Get["/tx/{id:int}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } var details = pool.PaymentRepository.GetPaymentDetailsByTransactionId((uint)_.id); if (details == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested transaction does not exist.") }]); } var account = pool.AccountManager.GetAccountById(details.AccountId); var block = pool.BlockRepository.Get((uint)details.Block); ViewBag.Header = string.Format("Transaction Details"); ViewBag.SubHeader = string.Format("{0}", details.TransactionId); var model = new PaymentDetailsModel { Details = details, Account = account, Block = block, Coin = pool.Config.Coin }; return(View["paymentdetails", model]); }; Get["/payment/{id:int}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } var details = pool.PaymentRepository.GeyPaymentDetailsByPaymentId((uint)_.id); if (details == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested payment does not exist.") }]); } var account = pool.AccountManager.GetAccountById(details.AccountId); var block = pool.BlockRepository.Get((uint)details.Block); ViewBag.Header = string.Format("Payment Details"); ViewBag.SubHeader = string.Format("{0}", details.PaymentId); var model = new PaymentDetailsModel { Details = details, Account = account, Block = block, Coin = pool.Config.Coin }; return(View["paymentdetails", model]); }; Get["/account/username/{username}/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } var account = (IAccount)pool.AccountManager.GetAccountByUsernameOrAddress(_.username); if (account == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested account does not exist: {0}", _.username) }]); } int page; if (!Int32.TryParse(_.page, out page)) { page = 1; } var paginationQuery = new PaginationQuery(page); // get the payments for the account. var payments = pool.AccountManager.GetPaymentsForAccount(account.Id, paginationQuery); ViewBag.Header = string.Format("Account Details"); ViewBag.SubHeader = account.Username; // return our view return(View["account", new AccountModel { Account = account, Coin = pool.Config.Coin, Payments = payments, PaginationQuery = paginationQuery }]); }; }