public async Task <IActionResult> Create([Bind(properties)] AccountView c)
        {
            c.ID = BankId.NewBankId();
            await validateId(c.ID, ModelState);

            if (!ModelState.IsValid)
            {
                return(View(c));
            }
            c.Balance = 500;
            c.Status  = Status.Active.ToString();
            //c.Type = Enum.GetName(typeof(CardType), int.Parse(c.Type));
            var loggedInUser = await userManager.GetUserAsync(HttpContext.User);

            c.AspNetUserId = loggedInUser.Id;
            var o = AccountFactory.CreateAccount(c.ID, c.Balance, c.Type, c.Status, c.AspNetUserId,
                                                 c.ValidFrom = DateTime.Now, c.ValidTo = DateTime.Now.AddYears(2));
            await repository.AddObject(o);

            await _bankHub.Clients.All.SendAsync("NewAccount", c.ID, c.Type, c.Balance, c.Status, c.ValidTo.Value.Date.ToShortDateString());

            await createWelcomeNotification(c.ID);
            await createWelcomeTransaction(c.ID);

            return(RedirectToAction("Index", "Home"));
        }
Example #2
0
 [TestMethod] public void IsIdTypeOfStringTest()
 {
     Assert.IsTrue(BankId.NewBankId().GetType() == typeof(string));
 }
Example #3
0
 private static string addAccount(ApplicationDbContext c, AccountData data)
 {
     data.ID = BankId.NewBankId();
     c.Accounts.Add(data);
     return(data.ID);
 }
Example #4
0
 [TestMethod] public void IsNotNullTest()
 {
     Assert.IsNotNull(BankId.NewBankId());
 }