public CreateAccountView()
        {
            var vm = new CreateAccountVM();

            this.BindingContext = vm;
            InitializeComponent();
        }
        public IViewComponentResult Invoke()
        {
            var accountTypes = Enum.GetValues(typeof(AccountType)).Cast <AccountType>().ToList();
            var model        = new CreateAccountVM
            {
                AccountTypes = accountTypes
            };

            return(View(model));
        }
Example #3
0
        public async Task <JsonResult> CreateAccount([FromBody] CreateAccountVM account)
        {
            //validate

            if (account.username == null || account.password == null || account.password2 == null)
            {
                return(Json(new JSONResponseVM {
                    success = false, message = "Please fill out all the fields"
                }));
            }
            if (account.password != account.password2)
            {
                return(Json(new JSONResponseVM {
                    success = false, message = "Passwords don't match"
                }));
            }

            //check to see if this username already exists
            var query = await context.Users.Where(u => u.username == account.username).FirstOrDefaultAsync();

            if (query != null)
            {
                //this username exists
                return(Json(new JSONResponseVM {
                    success = false, message = "A user with this username already exists"
                }));
            }


            string newPassword = account.password;

            newPassword = HashString.Hash(newPassword, config["salt"]);

            //now add the new user to the database
            User newUser = new User
            {
                username       = account.username,
                hashedPassword = newPassword,
                //the user is by default a customer
                role_id = 0,
                role    = await context.Roles.Where(r => r.role_id == 0).FirstOrDefaultAsync()
            };

            context.Users.Add(newUser);
            context.SaveChanges();

            //generate the token
            GenerateJWT jwtGen = new GenerateJWT();
            TokenVM     tok    = jwtGen.Generate(newUser.username, config);

            return(Json(new JSONTokenResponseVM {
                message = "Successfully created account: " + newUser.username, token = tok.token
            }));
        }
Example #4
0
        private void OnClickOriginate(object sender, EventArgs args)
        {
            Analytics.TrackEvent("Wallet | Account | Originate");
            var task = new CreateAccountVM(VM.Parent)
            {
                SelectedSource = VM.Account
            };

            Navigation.PushAsync(new OriginateAccountPage {
                BindingContext = task
            });
        }
Example #5
0
 public CreateAccountDialogBox()
 {
     this.InitializeComponent();
     vm                    = DataContext as CreateAccountVM;
     _imagePicker          = new FileOpenPicker();
     _imagePicker.ViewMode = PickerViewMode.Thumbnail;
     _imagePicker.SuggestedStartLocation = PickerLocationId.Desktop;
     _imagePicker.FileTypeFilter.Add(".jpg");
     _imagePicker.FileTypeFilter.Add(".jpeg");
     _imagePicker.FileTypeFilter.Add(".png");
     _imagePicker.FileTypeFilter.Add(".gif");
 }
        //GET: CreateHouseWithWizard
        public ActionResult CreateHouseWithWizard()
        {
            var accountVM = new CreateAccountVM
            {
                BAccountType = accountHelper.GetAccountTypeSelectList()
            };
            var wizard = new HouseWizardVM
            {
                CreateAccount = accountVM
            };

            return(View(wizard));
        }
Example #7
0
        public async Task <ActionResult> Edit(CreateAccountVM model)
        {
            try
            {
                var account = _mapper.Map <Account>(model.Account);
                var success = await _accountRepo.Update(account);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
Example #8
0
        // GET: AccountController/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            var account = await _accountRepo.FindById(id);

            var accountTypes  = Enum.GetValues(typeof(AccountType)).Cast <AccountType>().ToList();
            var mappedAccount = _mapper.Map <AccountVM>(account);
            var model         = new CreateAccountVM
            {
                Account      = mappedAccount,
                AccountTypes = accountTypes
            };

            return(View(model));
        }
Example #9
0
        public void CreateAccount(CreateAccountVM model, int houseId)
        {
            var newAccount = new BankAccount
            {
                Description         = model.BDescription,
                StartingBalance     = model.BStartingBalance,
                CurrentBalance      = model.BStartingBalance,
                LowBalanceThreshold = model.BLowBalanceThreshold,
                Created             = DateTime.Now,
                HouseholdId         = houseId,
                AccountTypeId       = model.SelectedAccountTypeId
            };

            db.Accounts.Add(newAccount);
        }
 public ActionResult Create(CreateAccountVM account)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(View(account));
         }
         accountDomain.AddAccount(account.Email, account.Password, account.Work);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #11
0
        public async Task <ActionResult> Create(CreateAccountVM model)
        {
            try
            {
                var account = model.Account;

                var mappedAccount = _mapper.Map <Account>(account);
                var success       = await _accountRepo.Create(mappedAccount);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #12
0
        public ActionResult SetAccount(CreateAccountVM model)
        {
            if (ModelState.IsValid)
            {
                #region Get user input
                Person p = new Person();
                p.Firstname = model.Firstname;
                p.Lastname  = model.Lastname;
                p.Username  = model.Username;
                p.Password  = model.Password;
                p.RoleId    = 2;
                #endregion

                #region Set Account
                bool exists = false;
                foreach (var item in dbo.GetAllPersons())
                {
                    if (p.Username.Trim() == item.Username.Trim() &&
                        p.Password.Trim() == item.Password.Trim())
                    {
                        exists = true;
                        break;
                    }
                }

                if (exists)
                {
                    ModelState.AddModelError(string.Empty, "Användarnamnet finns redan!");
                    return(View("CreateAccount"));
                }
                else
                {
                    db.Person.Add(p);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Home"));
                }
                #endregion
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Alla fält måste fyllas i!");
                return(View("CreateAccount"));
            }
        }
 public CreateAccount()
 {
     Vm          = new CreateAccountVM();
     DataContext = Vm;
     InitializeComponent();
 }