public static FundingTransaction Create(int entityId = 0, EntityType entityType = EntityType.Project) { return(FundingTransactionRepository.Create( UserFaker.Create(), entityId == 0 ? Rand.Int() : entityId, entityType, InvoiceFaker.Create(), 0.01M * Rand.SmallInt(), CurrencyType.Ethereum )); }
public void Create_WithoutInvoice_TransactionCreated() { var user = UserFaker.Create(); var project = ProjectFaker.Create(user); var tx = FundingTransactionRepository.Create( user, project.id, EntityType.Project, null, 0.05M, CurrencyType.BitCoin ); Assert.True(tx.id > 0); }
public void Create_DataCorrect_GotTransaction() { var user = UserFaker.Create(); var project = ProjectFaker.Create(user); var invoice = InvoiceFaker.Create(user, project.id); var tx = FundingTransactionRepository.Create( user, project.id, EntityType.Project, invoice, 0.05M, CurrencyType.BitCoin ); Assert.True(tx.id > 0); }
public RegisterBonus() { Post("/api/v1/schedule/user/register_bonus/start", _ => { var task = Task.Run(() => { int tokenBonus = Convert.ToInt32( AppConfig.GetConfiguration("user:registration:token_bonus") ); if (tokenBonus <= 0) { return; } int pageIndex = 1; var users = DL.Model.User.User.Paginate(pageIndex, 100); while (users.Length > 0) { foreach (var user in users) { try { if ( !user.EmailConfirmed() || FundingTransactionRepository.Get(user).Length > 0 ) { continue; } var balance = UserBalanceRepository.FindOrCreate(user, CurrencyType.GitComToken); balance.UpdateBalance(balance.balance + tokenBonus); FundingTransactionRepository.Create( user, user.id, EntityType.UserBalance, 2M, CurrencyType.GitComToken, "Registration bonus" ); } catch (Exception e) { SentrySdk.CaptureException(e); } } ++pageIndex; users = DL.Model.User.User.Paginate(pageIndex, 100); } }); JobsPool.Get().Push(task); return(HttpResponse.Data(new JObject())); }); }