示例#1
0
        public void RegisterUser(string name, string email, string password, EAccountType role, ref IdentityResult result)
        {
            if (role == EAccountType.Volunteer)
            {
                Volunteer v = new Volunteer {
                    Name = name, Email = email, UserName = email
                };
                result = UserManager.Create(v, password);

                if (result.Succeeded)
                {
                    UserManager.AddToRole(v.Id, role.ToString());
                    SignInManager.SignIn(v, isPersistent: false, rememberBrowser: false);
                }
            }

            else if (role == EAccountType.Ngo)
            {
                Ngo n = new Ngo()
                {
                    Name = name, Email = email, UserName = email
                };
                result = UserManager.Create(n, password);

                if (result.Succeeded)
                {
                    UserManager.AddToRole(n.Id, role.ToString());
                    SignInManager.SignIn(n, isPersistent: false, rememberBrowser: false);
                }
            }
        }
        private RecyclingPaymentDateCompareResult CompareAccount(double accountBalance, double paymentMoney, SignComparisonModes compareSign, EAccountType accountType)
        {
            accountBalance = Math.Round(accountBalance, 2);
            paymentMoney   = Math.Round(paymentMoney, 2);
            var isPassed       = true;
            var errorMsgFormat = string.Empty;

            switch (compareSign)
            {
            case SignComparisonModes.NotCompare:
                break;

            case SignComparisonModes.Equal:
                isPassed       = accountBalance == paymentMoney;
                errorMsgFormat = "{0}余额{1}应该等于需支付金额{2}";
                break;

            case SignComparisonModes.NotEqual:
                isPassed       = accountBalance != paymentMoney;
                errorMsgFormat = "{0}余额{1}不应该与需支付金额{2}相等";
                break;

            case SignComparisonModes.GreaterThan:
                isPassed       = accountBalance > paymentMoney;
                errorMsgFormat = "{0}余额{1}应该大于需支付金额{2}";
                break;

            case SignComparisonModes.LessThan:
                isPassed       = accountBalance < paymentMoney;
                errorMsgFormat = "{0}余额{1}应该小于需支付金额{2}";
                break;

            case SignComparisonModes.GreateThanEqual:
                isPassed       = accountBalance >= paymentMoney;
                errorMsgFormat = "{0}余额{1}小于需支付金额{2},余额不足";
                break;

            case SignComparisonModes.LessThanEqual:
                isPassed       = accountBalance <= paymentMoney;
                errorMsgFormat = "{0}余额{1}应该小于或等于需支付金额{2}";
                break;

            default:
                break;
            }

            return(new RecyclingPaymentDateCompareResult
            {
                IsPassed = isPassed,
                ErrorMsg = string.Format(errorMsgFormat, accountType.ToString(), string.Empty, string.Empty),
                ErrorDetail = string.Format(errorMsgFormat, accountType.ToString(),
                                            "[" + accountBalance.ToString("n2") + "]", "[" +  paymentMoney.ToString("n2") + "]"),
            });
        }
示例#3
0
		/////////////////////////////////////////////////////////////////////////////
		public Account FindAccount(EAccountType eType, bool bCreate)
		{
			// Loop thru all the accounts
			for (int i = 0; i < m_Accounts.Count; i++)
			{
				Account account = m_Accounts[i];

				// If we found a type match, return it
				if (account.AccountType == eType)
					return account;
			}

			// We didn't find the account and we won't create a new one, so get out
			if (!bCreate)
				return null;

			// Create a new account, by request
			Account accountNew = new Account();
			accountNew.AccountType = eType;
			accountNew.Name = eType.ToString();
			AddAccount(accountNew);
			return accountNew;
		}