// GET: Account/Details/5 public ActionResult Account(CustomerAccountViewModel view) { view = new CustomerAccountViewModel() { customer = new Customer(), //extraPickups = new List<ExtraPickup>() }; var currentUser = User.Identity.GetUserId(); //view.extraPickups = db.ExtraPickups.Where(e => e.CustomerId == currentUser).ToList(); Customer customer = db.Customers.Where(s => s.UserId == currentUser).SingleOrDefault(); view.customer = customer; var customers = db.Customers .Include(r => r.ApplicationUser) .FirstOrDefault(m => m.UserId == currentUser); if (customer == null) { return(HttpNotFound()); } return(View(view)); }
public async Task <CustomerAccount> AddCustomerAccountAsync(CustomerAccountViewModel accountViewModel) { var customer = await _context.Customers.Include(c => c.Accounts).FirstOrDefaultAsync(c => c.CustomerId == accountViewModel.CustomerId); if (customer.Accounts.Any(a => a.AccountClass == accountViewModel.AccountClass)) { throw new Exception($"Unable to create account. Customer already has a {accountViewModel.AccountClass} account in the system."); } if (accountViewModel.AccountClass == AccountClass.Loan) { throw new Exception("Wrong account class selected."); } var customerAccount = new CustomerAccount() { CustomerId = accountViewModel.CustomerId, IsActivated = accountViewModel.IsActivated, AccountClass = accountViewModel.AccountClass, AccountName = $"{customer.FirstName} {customer.LastName} {accountViewModel.AccountClass}", DateOpened = DateTime.Now }; _context.Add(customerAccount); await _context.SaveChangesAsync(); customerAccount.AccountNumber = GenerateCustomerAccountNumber(customerAccount.AccountClass, customerAccount.CustomerId, customerAccount.GLAccountId); _context.Update(customerAccount); await _context.SaveChangesAsync(); return(customerAccount); }
public async Task <ApiMessage> RegisterUser(CustomerAccountViewModel caViewModel) { var apiMsg = new ApiMessage(); try { var customerAccount = await DataCustomerAccessor.OneAsync <CustomerAccount>(x => x.OpenId == caViewModel.OpenId); if (customerAccount == null) { customerAccount = new CustomerAccount { OpenId = caViewModel.OpenId, NickName = caViewModel.NickName, Avatar = caViewModel.Avatar, Id = Guid.NewGuid() }; await DataCustomerAccessor.Add(customerAccount); } apiMsg.Data = customerAccount; } catch (Exception exc) { apiMsg.Message = exc.Message; apiMsg.Success = false; } return(apiMsg); }
public ActionResult Account() { ViewBag.Message = RoleName.USER_NAME; var branches = _context.Branches.ToList(); var customers = _context.Customers.ToList(); var loanDetails = _context.LoanDetails.ToList(); var accountTypes = _context.AccountTypes.ToList(); var customerAccounts = _context.CustomerAccounts.ToList(); var count = customerAccounts.Count(); var viewModel = new CustomerAccountViewModel { Branches = branches, Customers = customers, LoanDetails = loanDetails, AccountTypes = accountTypes, CustomerAccount = new CustomerAccount(), CustomerAccounts = customerAccounts, count = count }; if (User.IsInRole(RoleName.ADMIN_ROLE) || User.IsInRole(RoleName.USER_ROLE)) { return(View("CustomerAccount", viewModel)); } return(View("AccountReadOnly", viewModel)); }
public IActionResult Index() { var model = new CustomerAccountViewModel(); model.Accounts = _repo.Accounts; model.Customers = _repo.Customers; return(View(model)); }
public async Task EditCustomerAccountAsync(CustomerAccountViewModel accountViewModel) { var customerAccount = await RetrieveCustomerAccountAsync(accountViewModel.Id); customerAccount.AccountName = accountViewModel.AccountName; customerAccount.IsActivated = accountViewModel.IsActivated; _context.Update(customerAccount); await _context.SaveChangesAsync(); }
public IActionResult CustomerAccount() { var model = new CustomerAccountViewModel { StatusMessage = StatusMessage }; SetCustomerAccountViewItems(); return(View(model)); }
public IActionResult Index() { var model = new CustomerAccountViewModel() { Customers = _bankRepo.GetAllCustomers() }; return(View(model)); }
public async Task <IActionResult> UpdateCustomerAccount(CustomerAccountViewModel model) { var result = await _customerServiceRepository.UpdateCustomerAccountAsync(model); if (result == "Succeeded") { return(Ok()); } return(BadRequest(result)); }
public CustomerAccountViewModel GetAddCustomerAccount(int customerId, AccountClass accountClass) { var viewModel = new CustomerAccountViewModel { CustomerId = customerId, AccountClass = accountClass }; return(viewModel); }
public IActionResult Index() { var vm = new CustomerAccountViewModel { Accounts = _repo.Accounts, Customers = _repo.Customers }; return(View(vm)); }
public async Task <bool> ValidateCustomerAccount(CustomerAccountViewModel model) { response = await client.GetAsync("api.bankmodel/customerservice/account-exist/" + model); if (Convert.ToBoolean(response.Content.ReadAsStringAsync().Result) == true) { _validationDictionary.AddError("", string.Format(_config.GetSection("Messages")["ObjectExist"], string.Concat(model.Product, " for ", model.Customer))); } return(_validationDictionary.IsValid); }
// GET: MyAccount public async Task <IActionResult> Index() { var customer = await ecommerceContext.CurrentCustomer(); var customerModel = new CustomerAccountViewModel { Email = customer.Email, Name = customer.Name }; return(View(customerModel)); }
public ActionResult Edit(CustomerAccountViewModel model) { ViewData["Branches"] = context.Branches.ToList(); if (ModelState.IsValid) { CustomerAccount customerAccount = context.CustomerAccounts.Find(model.Id); customerAccount.Branch = context.Branches.Find(model.BranchID); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <string> UpdateCustomerAccountAsync(CustomerAccountViewModel model) { try { var account = _context.Accounts.Where(b => b.ID == model.ID).FirstOrDefault(); _context.Accounts.Update(account); await _context.SaveChangesAsync(); return("Succeeded"); } catch { return("Falied"); } }
public async Task <IActionResult> PostCustomerAccount([FromBody] CustomerAccountViewModel vm) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var customerAccount = new CustomerAccount { AccountName = vm.AccountName, Comments = vm.Comments, IsVisible = vm.IsVisible, CreatedAt = vm.CreatedAt, CreatedById = vm.CreatedById, UpdatedById = vm.UpdatedById, UpdatedAt = vm.UpdatedAt, }; using (var transaction = await _context.Database.BeginTransactionAsync()) { try { _context.CustomerAccounts.Add(customerAccount); await _context.SaveChangesAsync(); var accountRate = new AccountRate { CustomerAccountId = customerAccount.CustomerAccountId, RatePerHour = vm.RatePerHour, EffectiveStartDate = vm.EffectiveStartDate, EffectiveEndDate = vm.EffectiveEndDate, }; _context.AccountRates.Add(accountRate); await _context.SaveChangesAsync(); transaction.Commit(); return(CreatedAtAction("GetCustomerAccount", new { accId = customerAccount.CustomerAccountId, rateId = accountRate.AccountRateId }, customerAccount)); } catch (SqlException e) when(e.InnerException.Message.Contains("CustomerAccount_AccountName_UniqueConstraint")) { var message = $"The customer account {vm.AccountName} already exists in the database."; return(StatusCode(409, new { message })); } catch (Exception e) { return(BadRequest(new { message = e.InnerException.Message })); } } }
public async Task <bool> UpdateCustomerAccountAsync(CustomerAccountViewModel model) { var result = await ValidateCustomerAccount(model); if (!result) { return(false); } string accountModel = JsonConvert.SerializeObject(model); var contentData = new StringContent(accountModel, System.Text.Encoding.UTF8, "application/json"); response = client.PutAsync("api.bankmodel/customerservice/update-customer-account", contentData).Result; return(response.StatusCode == System.Net.HttpStatusCode.OK ? true : false); }
public async Task <IActionResult> Edit([Bind("Name,Email")] CustomerAccountViewModel customerModel) { if (ModelState.IsValid) { var customer = await ecommerceContext.CurrentCustomer(); customer.Email = customerModel.Email; customer.Name = customerModel.Name; await repository.UpdateCustomer(customer); return(RedirectToAction(nameof(Index))); } return(View(customerModel)); }
public async Task <CustomerAccountViewModel> GetEditCustomerAccount(int id) { var account = await RetrieveCustomerAccountAsync(id); var viewModel = new CustomerAccountViewModel { Id = account.GLAccountId, CustomerId = account.CustomerId, AccountClass = account.AccountClass, IsActivated = account.IsActivated, AccountName = account.AccountName, AccountNumber = account.AccountNumber }; return(viewModel); }
// GET: CustomerAccount/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerAccount customerAccount = context.CustomerAccounts.Include(b => b.Branch).SingleOrDefault(c => c.Id == id); if (customerAccount == null) { return(HttpNotFound()); } CustomerAccountViewModel model = new CustomerAccountViewModel(); model.BranchID = customerAccount.Branch.ID; ViewData["Branches"] = context.Branches.ToList(); return(View(model)); }
public ActionResult Create(CustomerAccountViewModel model) { ViewData["Branches"] = context.Branches.ToList(); ViewData["Customers"] = context.Customers.ToList(); if (ModelState.IsValid) { CustomerAccount customerAccount = new CustomerAccount(); customerAccount.AccNo = Helper.GenerateCustomerAccNo(model.AccountType, model.CustomerID); customerAccount.AccountType = (AccountType)model.AccountType; customerAccount.Balance = model.Balance; customerAccount.Branch = context.Branches.Find(model.BranchID); customerAccount.Customer = context.Customers.Find(model.CustomerID); context.CustomerAccounts.Add(customerAccount); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult UpdateIndividualProfile(IndividualProfileViewModel model) { //If here, then its individual profile update Result = await _customerService.UpdateCustomerAccountAsync(model); if (Result.Equals("Succeeded")) { StatusMessage = _config.GetSection("Messages")["Success"]; SetCustomerAccountViewItems(); return(RedirectToAction(nameof(CustomerAccountListing))); } else { model = new CustomerAccountViewModel { StatusMessage = "Error: Unable to update account" }; SetCustomerAccountViewItems(); return(View(model)); } }
public ActionResult CreateCustomerAccount(CustomerAccountViewModel customerAccountViewModel) { var branches = _context.Branches.ToList(); var customers = _context.Customers.ToList(); var loanDetails = _context.LoanDetails.ToList(); var accountTypes = _context.AccountTypes.ToList(); if (!ModelState.IsValid) { var viewModel = new CustomerAccountViewModel { Branches = branches, Customers = customers, LoanDetails = loanDetails, AccountTypes = accountTypes, CustomerAccount = new CustomerAccount() }; return(View("CustomerAccount", viewModel)); } var customerAccount = new CustomerAccount(); var customerId = customerAccountViewModel.CustomerAccount.CustomerId; customerAccount.Id = customerAccountViewModel.CustomerAccount.Id; customerAccount.AccountNumber = customerAccountViewModel.CustomerAccount.AccountTypeId.ToString() + customerId.ToString(); customerAccount.Name = customerAccountViewModel.CustomerAccount.Name; customerAccount.BranchId = customerAccountViewModel.CustomerAccount.BranchId; customerAccount.AccountTypeId = customerAccountViewModel.CustomerAccount.AccountTypeId; customerAccount.IsClosed = false; customerAccount.CustomerId = customerId; _context.CustomerAccounts.Add(customerAccount); _context.SaveChanges(); customerAccountViewModel.Customers = customers; customerAccountViewModel.Branches = branches; customerAccountViewModel.AccountTypes = accountTypes; customerAccountViewModel.LoanDetails = loanDetails; customerAccountViewModel.CustomerAccount = new CustomerAccount(); return(RedirectToAction("Account", "Customers"));; }
public IActionResult Create(CustomerAccountViewModel model) { var customerAccount = _mapper.Map <CustomerAccount>(model); customerAccount.CreatedDate = DateTime.Now; customerAccount.Status = 1; var customerAccountOwnCheques = new List <CustomerAccountOwnCheque>(); var customerAccountThirdPartyCheques = new List <CustomerAccountThirdPartyCheque>(); model.OwnChequesId.ForEach(item => { customerAccountOwnCheques.Add(new CustomerAccountOwnCheque() { OwnChequeId = item }); }); model.ThirdPartyChequesId.ForEach(item => { customerAccountThirdPartyCheques.Add(new CustomerAccountThirdPartyCheque() { ThirdPartyChequeId = item }); }); customerAccount.CustomerAccountOwnCheques = customerAccountOwnCheques; customerAccount.CustomerAccountThirdPartyCheques = customerAccountThirdPartyCheques; _context.CustomerAccounts.Add(customerAccount); var balanceSheets = _context.BalanceSheets.SingleOrDefault(c => c.BalanceSheetId == 1); if (balanceSheets != null) { balanceSheets.InHandCash -= customerAccount.InHandCash; } var flag = _context.SaveChanges(); var lastId = customerAccount.CustomerAccountId; return(Ok(flag > 0)); }
public async Task <IActionResult> Create([Bind("CustomerId,AccountClass,IsActivated")] CustomerAccountViewModel accountViewModel) { if (ModelState.IsValid) { try { await _gLAccountService.AddCustomerAccountAsync(accountViewModel); } catch (Exception ex) { ViewBag.Message = new StatusMessage { Message = ex.Message, Type = StatusType.Error }; return(View(accountViewModel)); } return(RedirectToAction(nameof(Index))); } return(View(accountViewModel)); }
public IActionResult CustomerAccountDetailView(string breadCumValue, long cusAccId) { if (HttpContext.Session.GetString("loggedIn") == null || HttpContext.Session.GetString("loggedIn") == "false") { return(RedirectToAction("Index", "Login")); } ViewBag.breadCumValue = breadCumValue; ViewBag.IsUpdate = cusAccId > 0 ? "true" : "false"; CustomerAccountViewModel customerAccountViewModel = new CustomerAccountViewModel(); if (cusAccId > 0) { customerAccountViewModel = (from a in _context.CustomerAccounts where a.CustomerAccountId == cusAccId select new CustomerAccountViewModel { CustomerAccountId = a.CustomerAccountId, Description = a.Description, Amount = a.Amount, AccountType = a.AccountType, CreatedDate = a.CreatedDate, Remark = a.Remark, CustomerId = a.CustomerId, CreatedBy = a.CreatedBy, Date = a.Date, OwnChequesId = a.CustomerAccountOwnCheques.Select(x => x.OwnChequeId).ToList(), ThirdPartyChequesId = a.CustomerAccountThirdPartyCheques.Select(x => x.ThirdPartyChequeId).ToList() }).Single(); } customerAccountViewModel.CustomerList = _context.Customers.Where(s => s.CurrentStatus == 1).Select(x => new Customer() { CustomerId = x.CustomerId, CustomerName = x.CustomerName }).ToList(); customerAccountViewModel.OwnChequesList = _context.OwnCheques.Select(x => new OwnCheque() { OwnChequeId = x.OwnChequeId, ChequeCode = x.ChequeCode, Amount = x.Amount }).ToList(); customerAccountViewModel.ThirdPartyChequesList = _context.ThirdPartyCheques.Select(x => new ThirdPartyCheque() { ThirdPartyChequeId = x.ThirdPartyChequeId, ChequeCode = x.ChequeCode, Amount = x.Amount }).ToList(); return(View(customerAccountViewModel)); }
public async Task <IActionResult> CustomerAccount(CustomerAccountViewModel model) { if (!ModelState.IsValid) { //model = new CustomerAccountViewModel { StatusMessage = "Please correct the errors" }; SetCustomerAccountViewItems(); return(View(model)); } var user = await _userManager.GetUserAsync(User); //If here, then its a new customer account model.ActionBy = user.UserName; Result = await _customerService.CreateCustomerAccountAsync(model); if (Result.Equals("Succeeded")) { //This gets the generated Account Number string accountNo = await _customerService.GetGeneratedAccountNo(); var accountMandateFileName = Path.Combine(_hostingEnvironment.WebRootPath, "assets/images/signature-mandates/" + accountNo + ".jpg"); using (var stream = new FileStream(accountMandateFileName, FileMode.Create)) { model.AccountMandate.CopyTo(stream); } StatusMessage = _config.GetSection("Messages")["Success"]; SetCustomerAccountViewItems(); return(RedirectToAction(nameof(CustomerAccount))); } model = new CustomerAccountViewModel { StatusMessage = "Error: Unable to create account" }; SetCustomerAccountViewItems(); return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,AccountName,IsActivated")] CustomerAccountViewModel accountViewModel) { if (id != accountViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await _gLAccountService.EditCustomerAccountAsync(accountViewModel); } catch (DbUpdateConcurrencyException) { if (!await _gLAccountService.GLAccountExists(accountViewModel.Id)) { return(NotFound()); } else { throw; } } catch (Exception ex) { ViewBag.Message = new StatusMessage { Message = ex.Message, Type = StatusType.Error }; return(View(accountViewModel)); } return(RedirectToAction(nameof(Index))); } return(View(accountViewModel)); }
public CustomerAccountListViewModel GetCustomerById(int Id) { CustomerAccountViewModel customerAcc = new CustomerAccountViewModel(); CustomerAccountListViewModel customerAccountList = new CustomerAccountListViewModel(); customerAccountList.CustomerAccountList = new List <CustomerAccountViewModel>(); if (Id != 0) { customerAccountList.Customer = _context.Customers.Include("Branch").Select(c => new CustomerViewModel { BranchName = c.Branch.BranchName, CustomerId = c.CustomerId, CustmerName = c.CustmerName, OpenDate = c.OpenDate }).FirstOrDefault(c => c.CustomerId == Id); var customerAccList = _context.CustomerAccounts.Include("Currency").Where(ca => ca.Customer.CustomerId == Id && !ca.IsClosed); if (customerAccList != null) { foreach (var Acc in customerAccList) { customerAcc = new CustomerAccountViewModel(); customerAcc.AccId = Acc.AccId; customerAcc.Acc_Number = Acc.Acc_Number; customerAcc.Acc_Type = Acc.Acc_Type; customerAcc.Openning_Bal = Math.Round(Acc.Openning_Bal, Acc.Currency.decimal_Digits); customerAcc.Class_Code = Acc.Class_Code; customerAcc.IsClosed = Acc.IsClosed; customerAcc.Currency = Acc.Currency.ISO_Code; customerAcc.CurrencyId = Acc.Currency.currencyId; customerAcc.CustomerId = Id;// Acc.Customer.CustomerId; customerAcc.currDecimal = Acc.Currency.decimal_Digits; customerAccountList.CustomerAccountList.Add(customerAcc); } } } else { } return(customerAccountList); }
public ActionResult Registration(CustomerAccountViewModel customer, string userId) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Manage")); } if (ModelState.IsValid) { #if true var config = new MapperConfiguration(cfg => { cfg.CreateMap <CustomerAccountViewModel, CustomerAccount>(); }); IMapper mapper = config.CreateMapper(); var entity = mapper.Map <CustomerAccountViewModel, CustomerAccount>(customer); #else var entity = new CustomerAccount { FirstName = customer.FirstName, LastName = customer.LastName, Phone = customer.Phone }; #endif using (var context = new AppDbContext()) { context.Set <CustomerAccount>().Add(entity); entity.EmailAddress = context.AspNetUsers.Where(x => x.Id.ToString() == userId).Select(y => y.Email).FirstOrDefault(); context.SaveChanges(); } return(RedirectToAction("Login", "Account")); } return(View()); }