public async Task <PaytopiaPaymentModel> AdminGetPayment(int id) { using (var context = DataContextFactory.CreateReadOnlyContext()) { var item = await context.PaytopiaPayments .AsNoTracking() .Where(x => x.Id == id) .Select(payment => new PaytopiaPaymentModel { Id = payment.Id, Type = payment.PaytopiaItem.Type, CurrencyId = payment.PaytopiaItem.CurrencyId, Amount = payment.Amount, Status = payment.Status, UserName = payment.User.UserName, IsAnonymous = payment.IsAnonymous, Begins = payment.Begins, Ends = payment.Ends, Timestamp = payment.Timestamp, TransferId = payment.TransferId, RefundId = payment.RefundId, ReferenceCode = payment.ReferenceCode, ReferenceId = payment.ReferenceId, RefundReason = payment.RefundReason, RequestData = payment.RequestData, }).FirstOrDefaultNoLockAsync().ConfigureAwait(false); var currency = await CurrencyReader.GetCurrency(item.CurrencyId).ConfigureAwait(false); item.Symbol = currency.Symbol; if (item.ReferenceId > 0) { if (item.Type == PaytopiaItemType.FeaturedCurrency || item.Type == PaytopiaItemType.LottoSlot || item.Type == PaytopiaItemType.RewardSlot || item.Type == PaytopiaItemType.TipSlot) { var refCurrency = await CurrencyReader.GetCurrency(item.ReferenceId).ConfigureAwait(false); if (refCurrency != null) { item.ReferenceName = refCurrency.Name; item.ReferenceAlgo = refCurrency.AlgoType; item.ReferenceSymbol = refCurrency.Symbol; } } else if (item.Type == PaytopiaItemType.FeaturedPool || item.Type == PaytopiaItemType.PoolListing) { var refPool = await PoolReader.GetPool(item.ReferenceId).ConfigureAwait(false); if (refPool != null) { item.ReferenceName = refPool.Name; item.ReferenceAlgo = refPool.AlgoType; item.ReferenceSymbol = refPool.Symbol; } } } return(item); } }
public async Task <IWriterResult> ChangeUserPool(string userId, ChangePoolModel model) { var currentUser = new Guid(userId); using (var context = PoolDataContextFactory.CreateContext()) { var pool = await PoolReader.GetPool(model.PoolId).ConfigureAwait(false); if (pool.Status != PoolStatus.OK) { return(new WriterResult(false, $"Pool #{model.PoolId} not found.")); } var userWorkers = await context.Worker.Where(x => x.UserId == currentUser && x.AlgoType == pool.AlgoType && x.IsEnabled).ToListNoLockAsync().ConfigureAwait(false); foreach (var worker in userWorkers) { if (model.AllWorkers || model.SelectedWorkers.Contains(worker.Id)) { worker.TargetPool = pool.Symbol; } } await context.SaveChangesAsync().ConfigureAwait(false); var message = model.AllWorkers ? $"Successfully moved all workers to the {pool.Name}({pool.Symbol}) pool." : $"Successfully moved selected workers to the {pool.Name}({pool.Symbol}) pool."; return(new WriterResult(true, message)); } }
public async Task <ActionResult> GettingStarted(int poolId) { var pool = await PoolReader.GetPool(poolId); var connection = await PoolReader.GetPoolConnection(pool.AlgoType); return(View("GettingStartedModal", new GettingStartedModel { PoolId = pool.Id, PoolName = pool.Name, PoolSymbol = pool.Symbol, AlgoType = pool.AlgoType, Port = connection.Port, StratumUrl = connection.Host })); }
public async Task <ActionResult> ChangeUserPool(int poolId) { var pool = await PoolReader.GetPool(poolId); var workers = await PoolWorkerReader.GetWorkers(User.Identity.GetUserId(), pool.AlgoType); if (workers.IsNullOrEmpty()) { return(ViewMessageModal(new ViewMessageModel(ViewMessageType.Warning, "No Workers Configured", "You do not have any workers configured, please create a worker in your accounts 'Miners' section"))); } return(View("ChangePoolModal", new ChangePoolModel { PoolId = pool.Id, PoolName = pool.Name, PoolSymbol = pool.Symbol, AlgoType = pool.AlgoType, Workers = workers, AllWorkers = true, SelectedWorkers = new List <int>() })); }