public ActionResult AddBank(AddBankDetails model)
 {
     if (!ModelState.IsValid || _bankService.BankExist(model.BranchId, model.Name) ||
         _bankService.BankCodeExist(model.BranchId, model.Code ?? 0)) return View(model);
     _bankService.AddBank(model.BranchId, new BankBO
     {
         Name = model.Name,
         Code = model.Code ?? 0
     });
     return RedirectToAction("BanksList", new { branchId = model.BranchId });
 }
Example #2
0
        public void AddNewBank()
        {
            Console.WriteLine("Please enter the new bank name");
            string bankName = Console.ReadLine();

            while (bankName == "")
            {
                Console.WriteLine("Bank Name cannot be empty");
                Console.Write("Please enter a valid bank name : ");
                bankName = Console.ReadLine();
            }

            Bank bank = new Bank()
            {
                Id                     = bankName.Substring(0, 3) + DateTime.Now,
                Name                   = bankName.ToLower(),
                RTGS_Charges           = 0,
                IMPS_Charges           = 0.05,
                Interbank_RTGS_Charges = 0.02,
                Interbank_IMPS_Charges = 0.06
            };
            Currency currency = new Currency()
            {
                Type         = "rupees",
                ExchangeRate = 0,
                BankId       = bank.Id
            };

            bankService.AddBank(bank);
            currencyService.AddCurrency(currency);

            User user = new User()
            {
                Name         = "Manager",
                UserName     = "******",
                MobileNumber = "9999999999",
                Password     = "******",
                Type         = "staff",
                Address      = "Hyderabad",
                Email        = "*****@*****.**",
                BankId       = bank.Id
            };

            userService.AddUser(user);
            Console.WriteLine("Bank " + bankName + " added successfully!!!");
            return;
        }
        public async Task <IActionResult> AddBank([FromBody] Bank bank)
        {
            var result = await _bankService.AddBank(bank);

            return(Ok(result));
        }