示例#1
0
        public Customer AddCustomer(AddCustomerViewModel profile)
        {
            Customer    customer    = new Customer();
            BaseProfile baseProfile = new BaseProfile();
            BaseAccount account     = new BaseAccount();

            baseProfile.Password   = GeneratePassword(profile);
            baseProfile.FirstName  = profile.FirstName;
            baseProfile.LastName   = profile.LastName;
            baseProfile.MiddleName = profile.MiddleName;
            baseProfile.Email      = profile.Email;
            baseProfile.Phone      = profile.Phone;
            account.Cash           = profile.Cash;

            baseProfile.BaseProfileId = customer.CustomerId;
            account.BaseAccountId     = customer.CustomerId;

            customer.Account = account;
            customer.Profile = baseProfile;

            BankContext db = new BankContext();

            db.Customers.Add(customer);
            db.SaveChanges();
            //SendEmailToCustomer(profile);


            Globals.CurrentAction = "CustomerManagement";
            return(customer);
        }
        public void StartApp()
        {
            double depositAmount    = 200;
            double withdrawalAmount = 20;
            string customerName     = "Roshan Kumar Singh";

            // Getting the account based on Factory Pattern.
            BaseAccount account = AccountFactory.GetInstance(AccountType.Checkings);

            account.CustomerName = customerName;

            output.Print("Account details for: " + account.CustomerName);
            output.Print();

            // Deposit
            Deposit(account, depositAmount / 1);
            Deposit(account, depositAmount / 2);
            Deposit(account, depositAmount / 4);
            Deposit(account, depositAmount / 8);
            Deposit(account, depositAmount / 16);

            // Withdrawal
            Withdraw(account, withdrawalAmount);

            // Display transactions
            DisplayTransactions(account.GetTransactions());

            // Wait for input.
            Console.ReadLine();
        }
        public void OpenAccount(string name, AccountType accountType, IAccountNumberCreateService accountNumberCreateService)
        {
            _ = name ?? throw new ArgumentNullException();
            _ = accountNumberCreateService ?? throw new ArgumentNullException();

            Account account;
            int     number = accountNumberCreateService.CreateAccountNumber();

            switch (accountType)
            {
            case AccountType.Base:
                account = new BaseAccount(number, name, 0, 0);
                break;

            case AccountType.Silver:
                account = new SilverAccount(number, name, 0, 0);
                break;

            case AccountType.Gold:
                account = new GoldAccount(number, name, 0, 0);
                break;

            case AccountType.Platinum:
                account = new PlatinumAccount(number, name, 0, 0);
                break;

            default:
                throw new ArgumentException();
            }

            accountRepository.Add(account);
        }
示例#4
0
        public async Task <IActionResult> Deposit(IFormCollection form)
        {
            double.TryParse(form["Amount"], out double amount);
            string strValue = form["SelectAcc"].ToString();

            int.TryParse(strValue, out int id);

            BaseAccount depositAcc = await GetMyAccount(id);

            try
            {
                depositAcc.Deposit(amount, form["Comment"]);
            }
            catch (Exception e)
            {
                ModelState.AddModelError(nameof(amount), e.Message);
                ViewBag.Amount = amount;
                return(View(await GetMyCustomer()));
            }

            await _context.SaveChangesAsync();

            //return Receipt(CustomerID, form["Comment"]);

            return(View("Receipt", (
                            depositAcc.Transactions.Last().TransactionType.ToString(),
                            depositAcc.Transactions.Last().TransactionID,
                            depositAcc.Transactions.Last().ModifyDate,
                            CustomerID,
                            id,
                            depositAcc.Transactions.Last().Amount,
                            depositAcc.Transactions.Last().Comment,
                            -1
                            )));
        }
示例#5
0
        // GET HIGHLIGHTED!!!
        public List <BaseAccount> GetHighlighted(bool high)
        {
            List <BaseAccount> list = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Accounts_SelectByHighlight"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Highlight", high);
            }
                                    , map : delegate(IDataReader reader, short set)
            {
                Account accountWizard = null;
                accountWizard         = MapAccount(reader);
                BaseAccount acc       = new BaseAccount();
                acc.AvatarUrl         = accountWizard.AvatarUrl;
                acc.Handle            = accountWizard.Handle;
                if (list == null)
                {
                    list = new List <BaseAccount>();
                }

                list.Add(acc);
            });

            return(list);
        }
示例#6
0
        public bool Update(BaseAccount baseAccount)
        {
            try
            {
                var local = _uow.Set <BaseAccount>()
                            .Local
                            .FirstOrDefault(f => f.ID == baseAccount.ID);
                if (local != null)
                {
                    _uow.Entry(local).State = EntityState.Detached;
                }

                //var local2 = _uow.Set<Saze>()
                //  .Local
                //  .FirstOrDefault(f => f.ID == baseAccount.Sazes.ID);
                //if (local2 != null)
                //{
                //    _uow.Entry(local).State = EntityState.Detached;
                //}
                _baseAccounts.Attach(baseAccount);

                _uow.Entry(baseAccount).State = EntityState.Modified;
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public static BankAccount ToBankAccount(DalBankAccount dalBankAccount)
        {
            BankAccount bankAccount;

            switch (dalBankAccount.AccountType)
            {
            case AccountType.Base:
            {
                bankAccount = new BaseAccount(AccountOwnersMapper.ToAccountOwner(dalBankAccount.AccountOwner), dalBankAccount.BankAccountNumber, dalBankAccount.InvoiceAmount, dalBankAccount.BonusScores, dalBankAccount.IsClosed);
            }
            break;

            case AccountType.Platinum:
            {
                bankAccount = new PlatinumAccount(AccountOwnersMapper.ToAccountOwner(dalBankAccount.AccountOwner), dalBankAccount.BankAccountNumber, dalBankAccount.InvoiceAmount, dalBankAccount.BonusScores, dalBankAccount.IsClosed);
            }
            break;

            case AccountType.Gold:
            {
                bankAccount = new GoldAccount(AccountOwnersMapper.ToAccountOwner(dalBankAccount.AccountOwner), dalBankAccount.BankAccountNumber, dalBankAccount.InvoiceAmount, dalBankAccount.BonusScores, dalBankAccount.IsClosed);
            }
            break;

            default:
            {
                bankAccount = new BaseAccount(AccountOwnersMapper.ToAccountOwner(dalBankAccount.AccountOwner), dalBankAccount.BankAccountNumber, dalBankAccount.InvoiceAmount, dalBankAccount.BonusScores, dalBankAccount.IsClosed);
            }
            break;
            }
            return(bankAccount);
        }
示例#8
0
        private BankAccount CreateAccountByType(BankUser bankUser, BankAccountType typeAccount)
        {
            if (bankUser == null)
            {
                throw new ArgumentNullException(nameof(bankUser));
            }

            BankAccount newAccount;

            switch (typeAccount)
            {
            case BankAccountType.Base:
                newAccount = new BaseAccount(bankUser);
                break;

            case BankAccountType.Gold:
                newAccount = new GoldAccount(bankUser);
                break;

            case BankAccountType.Platinum:
                newAccount = new PlatinumAccount(bankUser);
                break;

            default:
                throw new InvalidEnumArgumentException(nameof(typeAccount));
            }

            return(newAccount);
        }
示例#9
0
        private BankAccount UpdateAccounts(BankAccount account, bool isClosed = false, int amount = 0, int bonus = 0)
        {
            if (account == null)
            {
                throw new ArgumentNullException(nameof(account));
            }

            BankAccount newAccount;

            switch (account.TypeAccount)
            {
            case BankAccountType.Base:
                newAccount = new BaseAccount(account.User, account.AccountId, account.TypeAccount, (uint)(account.Amount + amount), (uint)(account.Bonus + bonus), isClosed);
                break;

            case BankAccountType.Gold:
                newAccount = new GoldAccount(account.User, account.AccountId, account.TypeAccount, (uint)(account.Amount + amount), (uint)(account.Bonus + bonus), isClosed);
                break;

            case BankAccountType.Platinum:
                newAccount = new PlatinumAccount(account.User, account.AccountId, account.TypeAccount, (uint)(account.Amount + amount), (uint)(account.Bonus + bonus), isClosed);
                break;

            default:
                throw new InvalidEnumArgumentException(nameof(account.TypeAccount));
            }

            return(newAccount);
        }
示例#10
0
        /// <summary>
        /// Creates new account of the given type and adds it to the storage
        /// </summary>
        /// <param name="accType"></param>
        /// <param name="owner"></param>
        /// <returns>account's id</returns>
        public string CreateNewAccount(AccountTypes accType, AccountOwner owner, IidGenerator generator, IPointsCounter counter)
        {
            if (owner == null)
            {
                throw new ArgumentNullException();
            }

            Account newAcc;

            switch (accType)
            {
            case AccountTypes.Basic:
                currStorage.Add(newAcc = new BaseAccount(owner, generator, counter));
                break;

            case AccountTypes.Golden:
                currStorage.Add(newAcc = new GoldenAccount(owner, generator, counter));
                break;

            case AccountTypes.Platinum:
                currStorage.Add(newAcc = new PlatinumAccount(owner, generator, counter));
                break;

            default:
                throw new Exception("Can't create an account");
            }

            return(newAcc.Accid);
        }
        /// <summary>
        /// Create new account in repository
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type">AccountType to choose what type of account we use</param>
        /// <param name="creator">Creates number for account</param>
        public void OpenAccount(string name, AccountType type, IAccountNumberCreateService creator)
        {
            Account acc;

            switch (type)
            {
            case AccountType.Base:
                acc = new BaseAccount(name, creator.GetNextNumber(name));
                break;

            case AccountType.Silver:
                acc = new SilverAccount(name, creator.GetNextNumber(name));
                break;

            case AccountType.Gold:     // Isn't implemented.
                acc = new SilverAccount(name, creator.GetNextNumber(name));
                break;

            default:
                acc = new BaseAccount(name, creator.GetNextNumber(name));
                break;
            }

            repos.AddToAccountList(acc);
            accountsCount++;
        }
示例#12
0
        /// <summary>
        /// Opens the account.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="accountType">The type of account.</param>
        /// <param name="id">The identifier.</param>
        public void OpenAccount(User user, AccountType accountType)
        {
            BankAccount bankAccount;
            string      id = this.GenerateAccountId(user.ToString() + " " + accountType.ToString());

            switch ((int)accountType)
            {
            case 0:
            {
                bankAccount = new BaseAccount(id, user, accountType, AccountStatus.Open, 0, 0);
                break;
            }

            case 1:
            {
                bankAccount = new GoldAccount(id, user, accountType, AccountStatus.Open, 0, 0);
                break;
            }

            case 2:
            {
                bankAccount = new PlatinumAccount(id, user, accountType, AccountStatus.Open, 0, 0);
                break;
            }

            default:
            {
                bankAccount = new BaseAccount(id, user, accountType, AccountStatus.Open, 0, 0);
                break;
            }
            }

            bankAccount.Status = AccountStatus.Open;
            this.bankAccounts.Create(bankAccount);
        }
示例#13
0
        /// <summary>
        /// Opens the account.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="accountType">The type of account.</param>
        /// <param name="id">The identifier.</param>
        public void OpenAccount(User user, AccountType accountType, out int id)
        {
            BankAccount bankAccount;

            switch ((int)accountType)
            {
            case 0:
            {
                bankAccount = new BaseAccount(user, accountType, AccountStatus.Open, 0, 0);
                break;
            }

            case 1:
            {
                bankAccount = new GoldAccount(user, accountType, AccountStatus.Open, 0, 0);
                break;
            }

            case 2:
            {
                bankAccount = new PlatinumAccount(user, accountType, AccountStatus.Open, 0, 0);
                break;
            }

            default:
            {
                bankAccount = new BaseAccount(user, accountType, AccountStatus.Open, 0, 0);
                break;
            }
            }

            bankAccount.Status = AccountStatus.Open;
            this.bankAccounts.Create(bankAccount);
            id = bankAccount.Id;
        }
        /// <summary>
        /// Creates new bank account with specified type and adds it to the repository
        /// </summary>
        /// <param name="accountOwner">Account owner</param>
        /// <param name="accountID">Account ID</param>
        /// <param name="invoiceAmount">Invoice amount</param>
        /// <param name="bonusScores">Bonus Scores</param>
        /// <param name="accountType">Account type</param>
        private void Create(AccountOwner accountOwner, string accountID, decimal invoiceAmount, double bonusScores, AccountType accountType)
        {
            BankAccount newAccount;

            switch (accountType)
            {
            case AccountType.Base:
            {
                newAccount = new BaseAccount(accountOwner, accountID, invoiceAmount, bonusScores);
                repository.AddAccount(Mappers.BankAccountsMapper.ToDalBankAccount(newAccount, AccountType.Base));
            }
            break;

            case AccountType.Platinum:
            {
                newAccount = new PlatinumAccount(accountOwner, accountID, invoiceAmount, bonusScores);
                repository.AddAccount(Mappers.BankAccountsMapper.ToDalBankAccount(newAccount, AccountType.Platinum));
            }
            break;

            case AccountType.Gold:
            {
                newAccount = new GoldAccount(accountOwner, accountID, invoiceAmount, bonusScores);
                repository.AddAccount(Mappers.BankAccountsMapper.ToDalBankAccount(newAccount, AccountType.Gold));
            }
            break;

            default:
            {
                newAccount = new BaseAccount(accountOwner, accountID, invoiceAmount, bonusScores);
                repository.AddAccount(Mappers.BankAccountsMapper.ToDalBankAccount(newAccount, AccountType.Base));
            }
            break;
            }
        }
        public void Add(string accType, string name, string lastname)
        {
            using (AcountStorageDB db = new AcountStorageDB())
            {
                Account acc = new BaseAccount(name, lastname);
                switch (accType)
                {
                case "Basic":
                    acc = new BaseAccount(name, lastname);
                    break;

                case "Gold":
                    acc = new GoldAccount(name, lastname);
                    break;

                case "Platinum":
                    acc = new PlatinumAccount(name, lastname);
                    break;
                }
                AcountModel acount = new AcountModel();
                acount.accid         = acc.AccId;
                acount.ownerName     = acc.OwnerName;
                acount.ownerLastname = acc.OwnerLastName;
                acount.balance       = acc.Balance;
                acount.bonusPoints   = acc.BonusPoints;
                acount.acouintType   = accType;
            }
        }
示例#16
0
        private BankAccount CreateAccounts(string accountId, string userId, string firstName, string lastName, BankAccountType typeAccount, uint amount, uint bonus, bool isClosed)
        {
            BankAccount newAccount;
            BankUser    bankUser = new BankUser(userId, firstName, lastName);

            switch (typeAccount)
            {
            case BankAccountType.Base:
                newAccount = new BaseAccount(bankUser, accountId, typeAccount, amount, bonus, isClosed);
                break;

            case BankAccountType.Gold:
                newAccount = new GoldAccount(bankUser, accountId, typeAccount, amount, bonus, isClosed);
                break;

            case BankAccountType.Platinum:
                newAccount = new PlatinumAccount(bankUser, accountId, typeAccount, amount, bonus, isClosed);
                break;

            default:
                throw new InvalidEnumArgumentException(nameof(typeAccount));
            }

            return(newAccount);
        }
        public Account OpenAccount(string owner, AccountType accountType, IAccountNumberCreateService creator)
        {
            Account account;

            string[] fullName = owner.Split();
            switch (accountType)
            {
            case AccountType.Base:
                account = new BaseAccount(creator.GenerateId(), fullName[0], fullName[1]);
                break;

            case AccountType.Silver:
                account = new SilverAccount(creator.GenerateId(), fullName[0], fullName[1]);
                break;

            case AccountType.Gold:
                account = new GoldAccount(creator.GenerateId(), fullName[0], fullName[1]);
                break;

            case AccountType.Platinum:
                account = new PlatinumAccount(creator.GenerateId(), fullName[0], fullName[1]);
                break;

            default:
                account = new BaseAccount(creator.GenerateId(), fullName[0], fullName[1]);
                break;
            }

            this.repository.AddAccount(account.ToDalAccount());
            return(account);
        }
        public void InitRepo()
        {
            var     mock       = new Mock <IRepository>();
            Account defaultAcc = new BaseAccount(1, "John", "Smith");

            mock.Setup(repo => repo.AddAccount(defaultAcc.ToDalAccount()));
        }
示例#19
0
 private void addOwnersEquityAccounts(BaseAccount baseAccount)
 {
     this.addMainAccount("equity", baseAccount.dbIncrease, baseAccount);
     this.addMainAccount("revenue", baseAccount.dbIncrease, baseAccount);
     this.addMainAccount("expense-cost", false, baseAccount);
     this.addMainAccount("expense", false, baseAccount);
 }
示例#20
0
 private BigInteger GetAmount(BaseAccount account, string denom)
 {
     return(account
            .Coins
            .First(c => string.Equals(c.Denom, denom, StringComparison.Ordinal))
            .Amount);
 }
 public JsonResult OnProfile(Register model)
 {
     try
     {
         if (db.BaseAccounts.Count(d => d.email == model.email && d.id != model.id) > 0)
         {
             return(Json(new { status = "error", message = $"This user already exists" }));
         }
         else if (db.BaseAccounts.Count(d => d.username == model.username && d.id != model.id) > 0)
         {
             return(Json(new { status = "error", message = $"This username already exists" }));
         }
         bool        logoff  = false;
         BaseAccount account = db.BaseAccounts.Find(model.id);
         if (account.email != model.email)
         {
             logoff = true;
         }
         account.email    = model.email;
         account.fullName = model.fullName;
         account.phone    = model.phone;
         db.SaveChanges();
         return(Json(new { status = "success", message = $"Your account has been updated successfully", process = logoff ? "$('#logout').click();" : "location.reload();" }));
     }
     catch (Exception ex)
     {
         return(Json(new { status = "error", message = ex.Message }));
     }
 }
示例#22
0
 public long Insert(BaseAccount klant)
 {
     if (klant == null)
     {
         throw new NullReferenceException("Geen product.");
     }
     return(context.Insert(klant));
 }
示例#23
0
        public IActionResult Account(BaseAccountDetailViewmodel vm)
        {
            BaseAccount baseAccount = accountConverter.ViewModelToModel(vm);

            baseAccount.Id = GetUserId();
            accountRepository.Update(baseAccount);
            return(RedirectToAction("Index", "Gebruiker"));
        }
示例#24
0
        public void Update()
        {
            EmptyLists();
            BaseAccount baseAccount = new BaseAccount(1, "klant", "*****@*****.**", "wachtwoord", 1);

            accountRepository = new AccountRepository(context);
            Assert.True(accountRepository.Update(baseAccount));
        }
示例#25
0
        // adding rating
        public async Task <IActionResult> Create(IFormCollection form)
        {
            var billPay = new BillPay {
            };

            //int.TryParse(form["AccountNumber"].ToString(), out int acNum);


            SessionAccountNumber = (int)HttpContext.Session.GetInt32(nameof(SessionAccountNumber));
            int id = SessionAccountNumber;

            billPay.AccountNumber = SessionAccountNumber;
            billPay.Amount        = double.Parse(form["Amount"]);
            billPay.CustomerID    = CustomerID;
            billPay.PayeeID       = int.Parse(form["PayeeID"]);
            billPay.Period        = (PeriodType)Enum.Parse(typeof(PeriodType), form["Period"]);
            billPay.ScheduleDate  = DateTime.Parse(form["ScheduleDate"]);
            billPay.ModifyDate    = DateTime.UtcNow;
            billPay.Count         = 0;
            billPay.Blocked       = false;

            if (ModelState.IsValid)
            {
                try
                {
                    var payee = await _context.Payees.FindAsync(billPay.PayeeID);

                    if (payee == null)
                    {
                        ModelState.AddModelError("PayeeID", "Selected payee doesn't exist. Chose from: [" + string.Join(", ", _context.Payees.Select(x => x.PayeeID).ToList()) + "]");

                        return(View(billPay));
                    }

                    myAccount = null;
                    await GetMyAccount(id);

                    if (myAccount.Balance < billPay.Amount)
                    {
                        ModelState.AddModelError("Amount", "You do not have sufficient Balance for this Amount!");

                        return(View(billPay));
                    }

                    _context.Update(billPay);
                    await _context.SaveChangesAsync();

                    myAccount = null;
                    //HttpContext.Session.Remove(nameof(SessionAccountNumber));
                    return(View("DisplayBP", await GetMyAccount(SessionAccountNumber)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
示例#26
0
文件: Program.cs 项目: p21816/Dasha
        static void Main(string[] args)
        {
            EntityModel db = new EntityModel();

            BLL.Interface.Entities.AccountHolder holder1 = new BLL.Interface.Entities.AccountHolder(1, "Darya", "Battalova");
            //AccountHolder holder2 = new AccountHolder(2, "Evgeniy", "Bazarov");
            BaseAccount baseAccount = new BaseAccount(1, "1234567", holder1);

            //GoldAccount goldAccount = new GoldAccount(1 , "5432123", holder2);


            baseAccount.AddMoney(100, new BaseAccountBonusCalculation());

            AccountService accountService = new AccountService(new AccountRepository(db));

            Console.WriteLine("1");
            accountService.CreateAccount(baseAccount);
            //accountService.CreateAccount(goldAccount);
            Console.WriteLine("2");


            using (db)
            {
                Console.WriteLine("item1");

                foreach (var u in db.Accounts)
                {
                    Console.WriteLine("item");
                    Console.WriteLine(u.ToString());
                }

                Console.WriteLine("item2");
            }



            //List<Account> accountList = new List<Account>();
            //accountList = (List<Account>)accountService.GetAllAccounts();

            //foreach(var i in accountList)
            //{
            //    Console.WriteLine(i.ToString());
            //}


            //Console.WriteLine("found account: " + accountService.GetAccountById(1).ToString());



            //accountService.DeleteAccount(baseAccount);

            //List<Account> accountList1 = new List<Account>();
            //accountList1 = (List<Account>)accountService.GetAllAccounts();
            //foreach (var i in accountList1)
            //{
            //    Console.WriteLine(i.ToString());
            //}
        }
示例#27
0
        private List <BankAccount> ReadFromFile()
        {
            List <BankAccount> bankAccounts = new List <BankAccount>();

            try
            {
                using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.OpenOrCreate)))
                {
                    while (reader.PeekChar() > -1)
                    {
                        string  id            = reader.ReadString();
                        int     status        = reader.ReadInt32();
                        decimal balance       = reader.ReadDecimal();
                        int     bonusPoints   = reader.ReadInt32();
                        string  userFirstName = reader.ReadString();
                        string  userLastName  = reader.ReadString();
                        int     accountType   = reader.ReadInt32();

                        User        user = new User(userFirstName, userLastName);
                        BankAccount bankAccount;
                        switch ((int)accountType)
                        {
                        case 0:
                        {
                            bankAccount = new BaseAccount(id, user, (AccountType)accountType, (AccountStatus)status, balance, bonusPoints);
                            break;
                        }

                        case 1:
                        {
                            bankAccount = new GoldAccount(id, user, (AccountType)accountType, (AccountStatus)status, balance, bonusPoints);
                            break;
                        }

                        case 2:
                        {
                            bankAccount = new PlatinumAccount(id, user, (AccountType)accountType, (AccountStatus)status, balance, bonusPoints);
                            break;
                        }

                        default:
                        {
                            bankAccount = new BaseAccount(id, user, (AccountType)accountType, (AccountStatus)status, balance, bonusPoints);
                            break;
                        }
                        }

                        bankAccounts.Add(bankAccount);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(bankAccounts);
        }
示例#28
0
        public async Task <IActionResult> Edit(IFormCollection form)
        {
            int SessionEditID;

            int.TryParse(form["editID"], out int id);

            if (id != 0)
            {
                System.Diagnostics.Debug.WriteLine(" BP ID : " + id);
                SessionEditID = id;
                HttpContext.Session.SetInt32(nameof(SessionEditID), SessionEditID);

                return(View(await _context.BillPays.FindAsync(id)));
            }

            else
            {
                SessionEditID        = (int)HttpContext.Session.GetInt32(nameof(SessionEditID));
                SessionAccountNumber = (int)HttpContext.Session.GetInt32(nameof(SessionAccountNumber));

                var billPay = new BillPay {
                };

                billPay.BillPayID     = SessionEditID;
                billPay.AccountNumber = SessionAccountNumber;
                billPay.Amount        = double.Parse(form["Amount"]);
                billPay.CustomerID    = CustomerID;
                billPay.PayeeID       = int.Parse(form["PayeeID"]);
                billPay.Period        = (PeriodType)Enum.Parse(typeof(PeriodType), form["Period"]);
                billPay.ScheduleDate  = DateTime.Parse(form["ScheduleDate"]);
                billPay.ModifyDate    = DateTime.UtcNow;
                billPay.Count         = 0;
                billPay.Blocked       = bool.Parse(form["Blocked"]);

                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Update(billPay);
                        await _context.SaveChangesAsync();

                        myAccount = null;
                        //acc.BillPays.Remove(acc.BillPays.Find(x => x.BillPayID == SessionEditID));
                        //acc.BillPays.Add(billPay);
                        //HttpContext.Session.Remove(nameof(SessionAccountNumber));
                        HttpContext.Session.Remove(nameof(SessionEditID));
                        //ActionResult action = new BillPayController(_context).DisplayBP(acc));
                        return(View("DisplayBP", await GetMyAccount(SessionAccountNumber)));
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
        }
示例#29
0
        static void Main(string[] args)
        {
            Service service = new Service();
            Account tmp     = new BaseAccount(new AccountHolder("Ivan", "Shaveko", "*****@*****.**"), 100);

            service.Open(tmp);
            System.Console.WriteLine(service.Repository.List[0].Balance);
            System.Console.ReadKey();
        }
示例#30
0
        public async Task <BaseAccount> Update(int id, BaseAccount entity)
        {
            using DbContextBase dbContext = _contextFactory.CreateDbContext();

            entity.Id = id;
            dbContext.Accounts.Update(entity);
            await dbContext.SaveChangesAsync();

            return(entity);
        }
示例#31
0
        public void TestInterface()
        {
            BaseAccount account = new BaseAccount();

            sqlMap.QueryForObject<IAccount>("GetInterfaceAccount", 1, account);

            Assert.AreEqual(1, account.Id, "account.Id");
            Assert.AreEqual("Joe", account.FirstName, "account.FirstName");
            Assert.AreEqual("Dalton", account.LastName, "account.LastName");
            Assert.AreEqual("*****@*****.**", account.EmailAddress, "account.EmailAddress");
        }