public static UserBalance FindOrCreate(UserModel user, CurrencyType currencyType)
 {
     return(Find(user) ?? Create(
                UserRepository.Find(user.id),
                currencyType
                ));
 }
예제 #2
0
        public static UserModel Create(string email, string login, string password)
        {
            var newUserId = UserModel.Create(email, login, password);

            DiscordWebhooks.SendEvent("system-events", $"New user #{newUserId} just signed up! Email: {email}");
            return(Find(newUserId));
        }
예제 #3
0
        public static UserBalance Create(
            UserModel user = null, decimal amount = 0, CurrencyType currencyType = CurrencyType.BitCoin
            )
        {
            user = user ?? UserFaker.Create();
            var id = UserBalance.Create(user, currencyType, amount);

            return(UserBalanceRepository.Find(id));
        }
        public static UsersVotepower FindOrCreate(UserModel user, Model.Project.Project project)
        {
            var votepower = UsersVotepower.Find(user, project);

            if (votepower == null)
            {
                votepower = Create(user, project);
            }
            return(votepower);
        }
예제 #5
0
        public static UserModel Find(int id)
        {
            var cached = ModelCache.Get("User", id);

            if (cached != null)
            {
                return((UserModel)cached);
            }
            var item = UserModel.Find(id);

            if (item != null)
            {
                ModelCache.Store("User", item.id, item);
            }
            return(item);
        }
예제 #6
0
        public static UserModel FindByGuid(string guid)
        {
            var cached = ModelCache.Get("User", guid);

            if (cached != null)
            {
                return((UserModel)cached);
            }

            var item = UserModel.FindByGuid(guid);

            if (item != null)
            {
                ModelCache.Store("User", item.guid, item);
            }
            return(item);
        }
예제 #7
0
        public static UserModel FindOrCreateByEmailAndLogin(
            string email, string login, string password = null, UserModel referral = null
            )
        {
            password ??= Rand.RandomString();

            var user = UserModel.FindByEmail(email);

            var loginUser = UserModel.FindByLogin(login);

            var baseLogin  = login;
            int postfixNum = 0;

            while (loginUser != null)
            {
                postfixNum++;
                login     = $"{baseLogin}_{postfixNum}";
                loginUser = UserModel.FindByLogin(login);
            }

            user ??= Create(email, login, password);

            UserBadge.Create(user, "Early adopter");

            int tokenRegisterBonus = System.Convert.ToInt32(
                AppConfig.GetConfiguration("user:registration:token_bonus")
                );

            if (tokenRegisterBonus > 0)
            {
                UserBalance.Create(user, CurrencyType.GitComToken, tokenRegisterBonus);
                FundingTransaction.Create(
                    user, user.id, EntityType.User, null, tokenRegisterBonus, CurrencyType.GitComToken
                    );
            }

            if (referral != null)
            {
                UserReferralRepository.Create(user, referral);
            }

            return(user);
        }
 public static UserBalance[] GetPositive(UserModel user, ushort limit = 10)
 {
     return(UserBalance.GetPositive(user, limit));
 }
 public static UserBalance Create(UserModel user, CurrencyType currencyType, decimal setBalance = 0)
 {
     return(Find(UserBalance.Create(user, currencyType, setBalance)));
 }
예제 #10
0
 public static UserBalance Find(UserModel user, CurrencyType currencyType) => UserBalance.Find(user, currencyType);
예제 #11
0
 public static UserBalance Find(UserModel user)
 {
     return(UserBalance.FindByUserId(user.id));
 }
 public static UsersVotepower Create(UserModel user, Model.Project.Project project)
 {
     return(Find(UsersVotepower.Create(user, project)));
 }
 public static UsersVotepower Find(UserModel user, Model.Project.Project project)
 {
     return(UsersVotepower.Find(user, project));
 }
예제 #14
0
 public static UserModel FindByLogin(string login)
 {
     return(UserModel.FindByLogin(login));
 }
예제 #15
0
 public static UserModel FindByEmail(string email)
 {
     return(UserModel.FindByEmail(email));
 }