public IActionResult Create(Account model)
 {
     if (ModelState.IsValid)
     {
         _Account.Add(model);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Exemple #2
0
 /// <summary>
 /// Sets the string value.
 /// </summary>
 /// <param name="account">The <see cref="IAccount"/></param>
 /// <param name="key">Key.</param>
 /// <param name="value">Value.</param>
 public static void SetStringValue(this IAccount account, string key, string value = null)
 {
     if (account.ContainsKey(key))
     {
         account[key] = value;
     }
     else
     {
         account.Add(key, value);
     }
 }
Exemple #3
0
 public async Task AddAccount(Account Account)
 {
     if (Account.IsValid())
     {
         if (_IAccount.GetEntityByMail(Account.Mail) == null)
         {
             await _IAccount.Add(Account);
         }
         else
         {
             Account.AddErro("Email", "E-mail já cadastrado.");
         }
     }
 }
Exemple #4
0
        public static async Task <bool> BankTransaction([OrchestrationTrigger] IDurableOrchestrationContext context)
        {
            var iterationLength   = context.GetInput <Tuple <int, int> >();
            var targetAccountPair = iterationLength.Item1;
            var length            = iterationLength.Item2;

            var sourceAccountId = $"src{targetAccountPair}-!{(targetAccountPair + 1) % 32:D2}";
            var sourceEntity    = new EntityId(nameof(Account), sourceAccountId);

            var destinationAccountId = $"dst{targetAccountPair}-!{(targetAccountPair + 2) % 32:D2}";
            var destinationEntity    = new EntityId(nameof(Account), destinationAccountId);

            // Add an amount to the first account
            var transferAmount = 1000;

            IAccount sourceProxy =
                context.CreateEntityProxy <IAccount>(sourceEntity);
            IAccount destinationProxy =
                context.CreateEntityProxy <IAccount>(destinationEntity);

            // we want the balance check to always succeeed to reduce noise
            bool forceSuccess = true;

            // Create a critical section to avoid race conditions.
            // No operations can be performed on either the source or
            // destination accounts until the locks are released.
            using (await context.LockAsync(sourceEntity, destinationEntity))
            {
                int sourceBalance = await sourceProxy.Get();

                if (sourceBalance > transferAmount || forceSuccess)
                {
                    await sourceProxy.Add(-transferAmount);

                    await destinationProxy.Add(transferAmount);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemple #5
0
        public ActionResult Register(AccountViewModel model)
        {
            if (ModelState.IsValid)
            {
                var newUser = _repository.GetUser(model.Name);

                if (newUser == null)
                {
                    if (newUser != _repository.Add(model.Name, model.Password, model.RoleId)) // если пользователь удачно добавлен в бд
                    {
                        FormsAuthentication.SetAuthCookie(model.Name, false);
                        return(RedirectToAction("Index", "Cars"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resources.Resource.ErrorRegistration);
                }
            }
            return(View("Register", CreateView()));
        }
 public void transfer(IAccount toAccount, decimal amount)
 {
     this.amount -= amount;
     toAccount.Add(amount);
 }
Exemple #7
0
 /// <summary>
 /// 添加一条数据
 /// </summary>
 /// <param name="model">数据实体</param>
 /// <returns></returns>
 public int Add(Models.APP.Account model)
 {
     return(dal.Add(model));
 }
Exemple #8
0
 public bool Add(E_Model.Account model)
 {
     return(dal.Add(model));
 }
 public bool Add(Account account)
 {
     return(_account.Add(account));
 }
Exemple #10
0
 public IActionResult GetAccount()
 {
     return(Ok(_account.Add()));
 }
Exemple #11
0
 public async Task Add(Account Objeto)
 {
     await _IAccount.Add(Objeto);
 }
Exemple #12
0
 public void create(Transaction transaction)
 {
     accountBusinessManager.Add(transaction);
 }
Exemple #13
0
 public void Add(Transaction transaction)
 {
     accountRepository.Add(transaction);
 }