public NewAccountPage() { InitializeComponent(); //Bind to ViewModel for entire Content Page. Binding is inherited by all children on the page BindingContext = new NewAccountViewModel(); }
public ActionResult SaveAccount(Account account) { if (!ModelState.IsValid) { var accountViewModel = new NewAccountViewModel { Account = account, AccountTypes = _context.AccountType.ToList() }; return(View(accountViewModel)); } _context.Account.Add(account); _context.SaveChanges(); var accountId = account.AccountId; var userId = (int)Session["userId"]; var accountUser = new AccountUser { AccountId = accountId, UserId = userId }; _context.AccountUser.Add(accountUser); _context.SaveChanges(); return(RedirectToAction("Index")); }
public NewAccount() { InitializeComponent(); DataContext = new NewAccountViewModel { CloseAction = () => Close() }; }
public ActionResult NewAccount(NewAccountViewModel nAccount, string create, string reset) { if (!string.IsNullOrEmpty(create)) { if (!isUser(nAccount.FirstName)) { User newUser = new User(); newUser.FirstName = nAccount.FirstName; newUser.LastName = nAccount.LastName; newUser.Email = nAccount.Email; newUser.EmailUpdates = nAccount.EmailUpdates; newUser.ProgramID = nAccount.ProgramID; Session["tempUser"] = newUser; return(View("Password")); } else { return(View("NewAccount")); } } else { ModelState.Clear(); return(View("NewAccount")); } }
/// <summary> /// convert new account view model to domain /// </summary> /// <param name="model"></param> /// <returns></returns> public ApplicationUser ConvertToDomain(NewAccountViewModel model) { ApplicationUser user = new ApplicationUser(); user.UserName = model.UserName; user.FirstName = model.FirstName; user.LastName = model.LastName; user.Email = model.Email; user.Phone = model.Phone; user.Department = model.Department; user.Position = model.Position; user.IsActive = true; if (model.Roles != null) { user.UserRoles = new List <ApplicationUserRole>(); foreach (var role in model.Roles) { if (role.Selected) { ApplicationUserRole userRole = new ApplicationUserRole(); { userRole.UserId = user.Id; userRole.RoleId = role.RoleId; } user.UserRoles.Add(userRole); } } } return(user); }
public async Task <IActionResult> Account([Required] NewAccountViewModel viewModel) { var account = await _userManager.FindByEmailAsync(viewModel.Email); if (account != null) { return(Conflict()); } account = new Account() { Email = viewModel.Email, UserName = viewModel.UserName }; var result = await _userManager.CreateAsync(account, viewModel.Password); if (!result.Succeeded) { return(BadRequest(result.Errors.Select(x => new { Code = x.Code, Description = x.Description }))); } return(Ok(new AccountGetViewModel() { Id = account.Id, Email = account.Email, UserName = account.UserName })); }
public ActionResult MortgageForm() { var viewModel = new NewAccountViewModel { Rate = 2 }; return(View(viewModel)); }
public ActionResult LoanForm() { var viewModel = new NewAccountViewModel { Rate = 10 }; return(View(viewModel)); }
public ActionResult CreditCardForm() { var viewModel = new NewAccountViewModel { Rate = 20 }; return(View(viewModel)); }
public ActionResult SavingsAccountForm() { var viewModel = new NewAccountViewModel { Rate = 1 }; return(View()); }
public ActionResult Add() { NewAccountViewModel navm = new NewAccountViewModel { UserLogin = Login, Mode = "Add" }; return(View("NewAccountForm", navm)); }
public async Task <IActionResult> Create() { var vm = new NewAccountViewModel { Roles = _role.Roles.Select(s => s.Name).ToList() }; return(View(vm)); }
public ActionResult AccountForm() { var accountTypes = _context.AccountType.ToList(); var accountViewModel = new NewAccountViewModel { Account = new Account(), AccountTypes = accountTypes }; return(View(accountViewModel)); }
public async Task <IActionResult> CreateTeacherAsync([FromBody] NewAccountViewModel account) { if (!ModelState.IsValid) { return(BadRequest(new ValidationError(ModelState))); } var newTeacher = await _teachersService.CreateTeacherAsync(_mapper.Map <TeacherDto>(account)); return(CreatedAtRoute("GetTeacher", new { teacherId = newTeacher.Id }, newTeacher)); }
public ActionResult RegistrationCompleted(NewAccountViewModel newAccount) { if (!ModelState.IsValid) { return(View("RegistrationForm")); } else { _repository.NewAccount(newAccount); return(View(newAccount.CardNumber)); } }
public void NewAccount(NewAccountViewModel newAccount) { var account = new Account() { CardNumber = newAccount.CardNumber, PinNumber = newAccount.PinNumber, Balance = newAccount.Balance }; _context.Accounts.Add(account); _context.SaveChanges(); }
public ActionResult Add() { var model = new NewAccountViewModel(); model.Roles = _userRepository.GetRoles().Select(x => new RoleViewModel() { RoleId = x.Id, RoleName = x.Name }).OrderBy(y => y.RoleName).ToList(); model.CurrentUser = User.Identity.GetUserName(); return(View(model)); }
public async Task <IActionResult> NewAccountAsync([FromBody] NewAccountViewModel model) { if (ModelState.IsValid) { var result = await _customerService.NewAccountNumberAsync(model); if (result.IsSuccess) { return(Ok(result)); //Status Code : 200 } return(BadRequest(result)); } return(BadRequest("Some properties are not valid")); //return code:400 }
public async Task <ActionResult> Register(NewAccountViewModel UserAccountModel) { // Ensure valid if (!ModelState.IsValid) { return(View(UserAccountModel)); } // Create a basic Kentico User and assign the portal ID var NewUser = _UserService.CreateUser(_UserService.BasicUserToIUser(UserAccountModel.User), UserAccountModel.Password); // Send confirmation email with registration link await _UserService.SendRegistrationConfirmationEmailAsync(NewUser as UserInfo, Url.Action("Confirmation", "Account", new object { }, protocol: Request.Url.Scheme)); // Displays a view asking the visitor to check their email and confirm the new account return(View("CheckYourEmail")); }
public ActionResult CreateCreditCardAccount(NewAccountViewModel model) { if (!ModelState.IsValid) { return(View("CreaditCardForm")); } using (var _context = new ApplicationDbContext()) { var uId = User.Identity.GetUserId(); var user = _context.Users.Single(u => u.Id == uId); //if already has a credit card if (_context.Accounts.Where(a => a.ApplicationUserId == uId) .Where(a => a is CreditCard).Count() > 0) { return(View("CreditCardForm")); } var accountId = 0; //generating accoun number var existingAccounts = _context.Accounts.Where(a => a.Id == accountId); var highestAccountId = _context.Accounts.Max(a => a.Id); accountId = highestAccountId++; //creating new credit card var newCc = new CreditCard { Limit = model.CreditCard.Limit, InterestRate = 20, SortCode = "12-34-56", Transactions = new List <Transaction>(), AccountNumber = highestAccountId.ToString().PadLeft(8, '0'), ApplicationUserId = uId, Name = model.CreditCard.Name, Type = "Credit Card Account", OpenDate = DateTime.Now }; _context.Accounts.Add(newCc); _context.SaveChanges(); } return(RedirectToAction("Index", "LoggedIn")); }
public async Task <IActionResult> Create(NewAccountViewModel vm) { if (ModelState.IsValid) { var user = new IdentityUser { UserName = vm.Usuario, Email = vm.Correo }; var resul = await _userManager.CreateAsync(user, vm.Contraseña); var usuarioentity = _mapper.Map <Users>(vm); usuarioentity.Tipo = vm.RoleSelect; usuarioentity.Estado = "Activo"; usuarioentity.Id = user.Id; if (resul.Succeeded) { var resulrol = await _userManager.AddToRoleAsync(user, vm.RoleSelect); if (resulrol.Succeeded) { await _adminrepository.Add(usuarioentity); if (vm.RoleSelect.Equals("cliente")) { var productentity = new ProductosUsers(); productentity.Id = DateTime.Now.ToString("HHyfffmm"); productentity.Idusuario = user.Id; productentity.Idtipo = 1; productentity.Tipo = "Principal"; productentity.Balance = vm.MontoInicial; await _productsrepository.Add(productentity); } return(RedirectToAction("Management")); } } } return(View()); }
public Customer SaveCustomer(CheckoutViewModel model, int?id) { Customer customer = db.Customers.Where(q => q.Email == model.Email).FirstOrDefault(); if (customer == null) { string password = CommonHelper.RandomString(12).ToLower(); customer = db.Customers.Add(new Customer() { Name = model.Name, Password = Hashing.HashPassword(password), Email = model.Email, Address = model.Address, Phone = model.Phone, Avatar = "/Content/Client/img/others/blank-avatar.png", CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, }); var newModel = new NewAccountViewModel() { Name = model.Name, Email = model.Email, Password = password, LoginUrl = CommonHelper.GetBaseUrl() + Url.Action("Login", "Customer"), }; Task.Factory.StartNew(() => { EmailHandler.Handle(newModel, newModel.Email, "New Account", "Views/Customer/Template/NewAccountTemplate.cshtml"); }); } else { customer.Name = model.Name; customer.Email = model.Email; customer.Address = model.Address; customer.Phone = model.Phone; db.Entry(customer).State = System.Data.Entity.EntityState.Modified; } return(customer); }
public async Task <JsonResult> Add(NewAccountViewModel model) { var operationResult = new OperationResult(); var user = _userRepository.GetUserByUserName(model.UserName); if (user == null) { try { ApplicationUser newUser = new UserConverter().ConvertToDomain(model); var result = await UserManager.CreateAsync(newUser, model.NewPassword); if (result.Succeeded) { _userRepository.LogUserRegister(user); operationResult.Success = true; } else { operationResult.Success = false; operationResult.Message = "Error occurred trying to create new user."; } } catch (Exception ex) { operationResult.Success = false; operationResult.Message = "Error occurred trying to create new user."; logger.ErrorFormat("Error occurred trying to create new user: {0} ", ex.ToString()); } } return(Json(operationResult, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Create(NewAccountViewModel account) { if (!ModelState.IsValid) { ViewData["AccountTypeId"] = new SelectList(_context.AccountTypes, "Id", "Name"); ViewData["InterestId_Checking"] = new SelectList(_context.InterestRates.Where(i => i.Type.Name == "Checking"), "Id", "Name"); ViewData["InterestId_Loan"] = new SelectList(_context.InterestRates.Where(i => i.Type.Name == "Loan"), "Id", "Name"); ViewData["InterestId_Investment"] = new SelectList(_context.InterestRates.Where(i => i.Type.Name == "Investment"), "Id", "Name"); return(View("New")); } var type = _context.AccountTypes.Find(account.TypeId); Accounts a = new Accounts() { Balance = 0, Name = account.Name, Active = true, Business = account.Business, Created = DateTime.Now, LastUpdated = DateTime.Now, Type = type, InterestId = account.InterestId }; switch (type.Name) { case "Checking": break; case "Investment": a.Balance = account.Amount.Value; var years = _context.InterestRates.Find(account.InterestId).Years.Value; a.TermAccounts.Add(new TermAccounts() { MaturationDate = DateTime.Now.AddYears(years), }); break; case "Loan": a.Balance = -account.Amount.Value; a.DebtAccounts.Add(new DebtAccounts() { PaymentAmount = 250.00M, //TODO Don't hardcode PaymentsBehind = 1, NextPaymentDue = DateTime.Now.AddMonths(1) }); break; default: _logger.LogWarning($"Invalid account type '{account.Name}'."); return(RedirectToAction(nameof(Index))); // TODO Error } using (var transaction = _context.Database.BeginTransaction()) { try { var userId = UID(); if (userId is null) { return(NotFound("uid null")); } if (_context.Customers.Find(userId) is null) { return(NotFound("user not found")); } Accounts added = _context.Accounts.Add(a).Entity; await _context.SaveChangesAsync(); if (_context.Accounts.Find(added.Id) is null) { return(NotFound("no acct")); } _context.CustomersToAccounts.Add(new CustomersToAccounts() { AccountId = added.Id, CustomerId = UID() }); await _context.SaveChangesAsync(); await transaction.CommitAsync(); } catch (Exception e) { _logger.LogError("Create account failed.", e); throw e; // Not this } } return(RedirectToAction(nameof(Index))); }
private void refreshContext() { viewModel = new NewAccountViewModel(); companyViewSource.Source = viewModel.Context.Companies.Local; aspnet_UsersViewSource.Source = viewModel.Context.aspnet_Users.Local; }
public NewAccountCommand(NewAccountViewModel newAccountViewModel) { currentViewModel = newAccountViewModel; }
public async Task <NewAccountResponse> NewAccountNumberAsync(NewAccountViewModel model) { try { if (model == null) { throw new NullReferenceException("New Account Model is Null"); } // Email, Phone and ConsumerName //generate account number var AccountNumber = ApiUtil.RandomDigits(); //check if account number already exists var result = _context.CustomerAccounts.FirstOrDefault(z => z.AccountNumber == AccountNumber); if (result == null) //if account does not exist { //get merchant var merchantId = _context.MerchantAccounts.FirstOrDefault(x => x.ApiKey == model.HashCode).MerchantAccountId; if (merchantId != 0) { //create cust as user var user = new User(); user.Email = model.Email; user.Role = "Customer"; user.Password = "******"; //not tied to aspnetUser user.CreatedOn = DateTime.Now; await _context.Users.AddAsync(user); await _context.SaveChangesAsync(); //create customer with account var cust = new CustomerAccount(); cust.MerchantAccountId = merchantId; cust.AccountName = model.CustomerName; cust.AccountNumber = AccountNumber; cust.Phone = model.Phone; cust.CreatedOn = DateTime.Now; cust.Balance = 0; cust.UserId = user.UserId; await _context.CustomerAccounts.AddAsync(cust); await _context.SaveChangesAsync(); } } else { throw new NullReferenceException("New Account already exists"); } return(new NewAccountResponse { AccountNumber = AccountNumber.ToString(), Message = "Customer Account created successfully", IsSuccess = true }); } catch (Exception ex) { throw new NullReferenceException(ex.Message); } }
public NewAccountDialogService(NewAccountViewModel newAccountViewModel) { dialogVM = newAccountViewModel; dialogVM.OnPressOK += DialogVM_OnPressOK; }
public ActionResult NewAccount() { NewAccountViewModel NewUserAccount = new NewAccountViewModel(); return(View("NewAccount", NewUserAccount)); }
protected override void OnStartup(StartupEventArgs eventArgs) { base.OnStartup(eventArgs); TelemetryService.Initialize(); TelemetryService.PublishUsage(Environment.MachineName, GetAppAssemblyVersion(), "OnStartup", Phase.Start); log4net.Config.XmlConfigurator.Configure(); Uri uri = new Uri("_Resources/Icons.xaml", UriKind.Relative); ResourceDictionary dict = new ResourceDictionary { Source = uri }; var mainView = new MainView(); var messageService = new MessageService(mainView); _appInstaller = new Installer(messageService); var toolbar = new ToolbarViewModel(); var profileManager = new UserProfileManager(); var activityManager = new InactiveTransactionsManager(); var categoriesMap = new CategoriesViewModel(); var dataLoader = new DataLoader(profileManager); var dateStateVm = new DateStateViewModel(); var auditor = new Auditor(dataLoader, dateStateVm); var newAccountVm = new NewAccountViewModel(dataLoader); var newCategoryVm = new NewCategoryViewModel(); var accountsVm = new AccountsViewModel(dataLoader, auditor, dateStateVm); var incomeVm = new IncomeViewModel(dataLoader, auditor, dateStateVm); var expensesVm = new ExpensesViewModel(dataLoader, auditor, dateStateVm, categoriesMap); var budgetVm = new BudgetViewModel(dataLoader, auditor, dateStateVm, categoriesMap); var analysisVm = new AnalysisViewModel(); var settingsVm = new SettingsViewModel(); var mainVm = new MainViewModel(dataLoader, toolbar, accountsVm, newAccountVm, newCategoryVm, budgetVm, dateStateVm); toolbar.Items.Add(new ToolboxItemViewModel("Accounts", dict["appbar_layer"] as Canvas, accountsVm, mainVm, true)); toolbar.Items.Add(new ToolboxItemViewModel("Income", dict["appbar_graph_line_up"] as Canvas, incomeVm, mainVm)); toolbar.Items.Add(new ToolboxItemViewModel("Expenses", dict["appbar_graph_line_down"] as Canvas, expensesVm, mainVm)); toolbar.Items.Add(new ToolboxItemViewModel("Budget", dict["appbar_billing"] as Canvas, budgetVm, mainVm)); toolbar.Items.Add(new ToolboxItemViewModel("Analysis", dict["appbar_graph_bar"] as Canvas, analysisVm, mainVm)); toolbar.Items.Add(new ToolboxItemViewModel("Settings", dict["appbar_settings"] as Canvas, settingsVm, mainVm)); mainView.DataContext = mainVm; mainView.Show(); mainView.Closing += (s, e) => { mainVm.Dispose(); accountsVm.Dispose(); expensesVm.Dispose(); activityManager.Dispose(); TelemetryService.PublishUsage(Environment.MachineName, GetAppAssemblyVersion(), "Closing", Phase.End); }; dataLoader.LoadAsync(); TelemetryService.PublishUsage(Environment.MachineName, GetAppAssemblyVersion(), "OnStartup", Phase.End); }
public NewAccountPage() { InitializeComponent(); BindingContext = new NewAccountViewModel(); }