コード例 #1
0
        public async Task AmountCorrectlyFormattedOnSave(string cultureString, string amountString, decimal expectedAmount)
        {
            // Arrange
            var cultureInfo = new CultureInfo(cultureString);

            Thread.CurrentThread.CurrentCulture   = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;

            var mediatorMock          = new Mock <IMediator>();
            var mapperMock            = new Mock <IMapper>();
            var navigationServiceMock = new Mock <INavigationService>();
            var dialogServiceMock     = new Mock <IDialogService>();

            var addAccountVm = new AddAccountViewModel(mediatorMock.Object,
                                                       mapperMock.Object,
                                                       dialogServiceMock.Object,
                                                       navigationServiceMock.Object);

            addAccountVm.SelectedAccount.Name = "Foo";

            // Act
            addAccountVm.AmountString = amountString;
            await addAccountVm.SaveCommand.ExecuteAsync();

            // Assert
            addAccountVm.SelectedAccount.CurrentBalance.ShouldEqual(expectedAmount);
        }
コード例 #2
0
        private void ButtonSignUp_Click(object sender, RoutedEventArgs e)
        {
            try {
                AddAccountViewModel info = new AddAccountViewModel();
                info.Login           = Login.Text;
                info.Password        = Password.Text;
                info.Name            = Name.Text;
                info.TelephoneNumber = Phone.Text;
                info.Email           = Email.Text;

                HttpWebRequest httpWebRequest = WebRequest.CreateHttp("http://localhost:2202/api/UserAccount/register");
                httpWebRequest.Method      = "POST";
                httpWebRequest.ContentType = "application/json";
                using (StreamWriter Writer = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    Writer.Write(JsonConvert.SerializeObject(info));
                }

                WebResponse response = httpWebRequest.GetResponse();

                Title.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1A8733"));
                Title.Text       = "Successfully";
            }
            catch (Exception ex) {
                Title.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFB20920"));
                Title.Text       = "Bad data";
                MessageBox.Show(ex.InnerException.Message);
            }
        }
コード例 #3
0
        public async Task <ActionResult> Register(AddAccountViewModel model)
        {
            ApplicationDbContext appDb = new ApplicationDbContext();

            if (ModelState.IsValid)
            {
                // create a Enterprise table entry and a user table entry
                var Enterprise = new Account {
                    UserName = model.Email, Email = model.Email, Status = "registered", PhoneNumber2 = model.PhoneNumber2, Designation = model.Designation, Address = model.Address, FirstName = model.FirstName
                };
                var result = await UManager.CreateAsync(Enterprise, model.Password);

                if (result.Succeeded)
                {
                    var addedToRole = await UManager.AddToRoleAsync(Enterprise.Id, "Administrator");

                    if (addedToRole.Succeeded)
                    {
                        return(RedirectToAction("Login"));
                    }
                }
                AddErrors(result);
            }
            return(View(model));
        }
コード例 #4
0
        public ActionResult AddAccount()
        {
            AddAccountViewModel model = new AddAccountViewModel();

            model.Id = db.Roles;
            return(View(model));
        }
コード例 #5
0
 public AddAccount(int accountType)
 {
     InitializeComponent();
     BindingContext   = viewModel = new AddAccountViewModel();
     this.accountType = accountType;
     PopulatePicker();
 }
コード例 #6
0
ファイル: UserAccountsApi.cs プロジェクト: Tehl/bank-api
        public virtual IActionResult ApiV1UsersAddAccount(
            [FromRoute][Required] int?user_id,
            [FromBody] AddAccountViewModel accountData
            )
        {
            //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(200, default(AccountOverviewViewModel));

            //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(400, default(ErrorViewModel));

            //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(404, default(ErrorViewModel));

            string exampleJson = null;

            exampleJson =
                "{\r\n  \"account_id\" : 1,\r\n  \"bank_id\" : \"BizfiBank\",\r\n  \"account_number\" : \"00112233\"\r\n}";

            var example = exampleJson != null
                ? JsonConvert.DeserializeObject <AccountOverviewViewModel>(exampleJson)
                : default(AccountOverviewViewModel);

            //TODO: Change the data returned
            return(new ObjectResult(example));
        }
コード例 #7
0
        public PartialViewResult AddAccount()
        {
            var userId  = User.Identity.GetUserId();
            var user    = db.Users.Find(userId);
            var HouseId = user.HouseholdId;
            var Bank    = new List <Bank>();
            var Banks   = db.Banks.Where(i => i.HouseholdId == HouseId).ToList();

            foreach (var bank in Banks)
            {
                Bank.Add(bank);
            }
            var Type  = new List <AccountType>();
            var Types = db.AccountTypes.ToList();

            foreach (var type in Types)
            {
                Type.Add(type);
            }
            var add = new AddAccountViewModel
            {
                Banks = Bank,
                Types = Type
            };

            ViewBag.Banks = new SelectList(Bank, "Id", "Name");
            ViewBag.Type  = new SelectList(Type, "Id", "Type");


            return(PartialView("~/Views/Shared/_AddAccount.cshtml", add));
        }
コード例 #8
0
        static void Main(string[] args)
        {
            AddAccountViewModel addAccountViewModel = new AddAccountViewModel();

            addAccountViewModel.AuthenticateUserResponse();

            addAccountViewModel.AuthenticateUserResponse();
        }
コード例 #9
0
        public void Ctor_CategoryCreated()
        {
            // Arrange
            // Act
            var mediator = new Mock <IMediator>();

            var addAccountVm = new AddAccountViewModel(mediator.Object, null, null, null);

            // Assert
            addAccountVm.SelectedAccount.ShouldNotBeNull();
        }
コード例 #10
0
        public ActionResult AddAccount()
        {
            var        cards           = CardService.FindUserCards(User.Identity.GetUserId()).ToList();
            SelectList cardsSelectList = new SelectList(cards, "Id", "Number");
            var        model           = new AddAccountViewModel
            {
                Cards = cardsSelectList
            };

            return(View(model));
        }
コード例 #11
0
        public AddAccount(int accountID, int accountType)
        {
            InitializeComponent();
            BindingContext = viewModel = new AddAccountViewModel();

            this.accountID   = accountID;
            this.accountType = accountType;
            PopulatePicker();
            PopulateOnEdit();
            saveButton.Text = "Update";
        }
コード例 #12
0
        public void Ctor_Title_Set()
        {
            // Arrange
            // Act
            var crudServiceMock = new Mock <ICrudServicesAsync>();

            var addAccountVm = new AddAccountViewModel(crudServiceMock.Object, null, null, null, null);

            // Assert
            addAccountVm.Title.ShouldEqual(Strings.AddAccountTitle);
        }
コード例 #13
0
        public void Ctor_Title_Set()
        {
            // Arrange
            // Act
            var mediator = new Mock <IMediator>();

            var addAccountVm = new AddAccountViewModel(mediator.Object, null, null, null, null, null);

            // Assert
            addAccountVm.Title.ShouldEqual(Strings.AddAccountTitle);
        }
コード例 #14
0
        public async Task AmountStringSetOnInit()
        {
            // Arrange
            var mediator     = new Mock <IMediator>();
            var addAccountVm = new AddAccountViewModel(mediator.Object, null, null, null);

            // Act
            await addAccountVm.InitializeCommand.ExecuteAsync();

            // Assert
            addAccountVm.AmountString.ShouldEqual("0.00");
        }
コード例 #15
0
        public void Ctor_CategoryCreated()
        {
            // Arrange
            // Act
            var crudServiceMock = new Mock <ICrudServicesAsync>();

            var addAccountVm = new AddAccountViewModel(crudServiceMock.Object, null, null, null, null);


            // Assert
            addAccountVm.SelectedAccount.ShouldNotBeNull();
        }
コード例 #16
0
        public void Prepare_Title_Set()
        {
            // Arrange
            var crudServiceMock = new Mock <ICrudServicesAsync>();

            var addAccountVm = new AddAccountViewModel(crudServiceMock.Object, null, null, null, null, null);

            // Act
            addAccountVm.Prepare(new ModifyAccountParameter());

            // Assert
            addAccountVm.Title.ShouldEqual(Strings.AddAccountTitle);
        }
コード例 #17
0
        public void Prepare_CategoryCreated()
        {
            // Arrange
            var crudServiceMock = new Mock <ICrudServicesAsync>();

            var addAccountVm = new AddAccountViewModel(crudServiceMock.Object, null, null, null, null, null);

            // Act
            addAccountVm.Prepare(new ModifyAccountParameter());

            // Assert
            addAccountVm.SelectedAccount.ShouldNotBeNull();
        }
コード例 #18
0
        public async Task <IActionResult> AddAccount(AddAccountViewModel accountModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Account model is not valid."));
            }
            else
            {
                var account = AddAccountToAccountDTOMapper.Instance.Map(accountModel);
                await accountService.AddAccount(account);

                return(RedirectToAction(nameof(GetAllAccounts)));
            }
        }
コード例 #19
0
        public ActionResult AddAccount(AddAccountViewModel model)
        {
            Account account = new Account()
            {
                AccountCode    = model.AccountCode,
                AccountName    = model.AccountName,
                AccountClassId = model.AccountClass,
                Description    = model.Description
            };

            _financialService.AddAccount(account);

            return(RedirectToAction("Accounts"));
        }
コード例 #20
0
        public ActionResult AddAccount(AddAccountViewModel model)
        {
            Account account = new Account()
            {
                AccountCode     = model.AccountCode,
                AccountName     = model.AccountName,
                AccountClassId  = model.AccountClass,
                ParentAccountId = model.ParentAccountId == -1 ? null : model.ParentAccountId,
                CompanyId       = _administrationService.GetDefaultCompany().Id,
            };

            _financialService.AddAccount(account);

            return(RedirectToAction("Accounts"));
        }
コード例 #21
0
        public ActionResult Add(int id)
        {
            var model = new AddAccountViewModel()
            {
                Id = id
            };

            if (_repositoryClient.Get(id) != null)
            {
                return(View(model));
            }
            else
            {
                return(RedirectToAction("PageNotFound", "Error"));
            }
        }
コード例 #22
0
        public async Task <IActionResult> AddAccount(int id)
        {
            var person = await personService.GetPersonById(id);

            if (person != null)
            {
                var accountVM = new AddAccountViewModel()
                {
                    Number   = accountService.GenerateCardNumber(16),
                    Person   = person,
                    PersonId = id
                };
                return(View(accountVM));
            }
            ;
            return(NotFound("Sorry. Current user not found"));
        }
コード例 #23
0
        public async Task <IActionResult> Register([FromBody] AddAccountViewModel model)
        {
            UserAccount user = new UserAccount()
            {
                UserName    = model.Login,
                Name        = model.Name,
                PhoneNumber = model.TelephoneNumber,
                Email       = model.Email
            };
            var result = await _userManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                return(Ok());
            }
            return(BadRequest("Bad request(FromRegistr)"));
        }
コード例 #24
0
        public ActionResult AddAccount(AddAccountViewModel model)
        {
            Account account = new Account()
            {
                AccountCode     = model.AccountCode,
                AccountName     = model.AccountName,
                AccountClassId  = model.AccountClass,
                ParentAccountId = model.ParentAccountId == -1 ? null : model.ParentAccountId,
                CreatedBy       = User.Identity.Name,
                ModifiedBy      = User.Identity.Name,
                CreatedOn       = DateTime.Now,
                ModifiedOn      = DateTime.Now
            };

            _financialService.AddAccount(account);

            return(RedirectToAction("Accounts"));
        }
コード例 #25
0
        public ActionResult Delete(int id)
        {
            var model = _repository.Get(id);

            if (model != null)
            {
                var vm = new AddAccountViewModel()
                {
                    Id = id
                };
                ViewBag.PersonName = model.Name;
                return(View(vm));
            }
            else
            {
                return(RedirectToAction("PageNotFound", "Error"));
            }
        }
コード例 #26
0
        public async Task <IActionResult> AddAccount(AddAccountViewModel accountModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Account model is not valid."));
            }
            else
            {
                var account = AddAccountToAccountDTOMapper.Instance.Map(accountModel);
                var result  = await apiBankAccountService.AddAccount(account);

                var validateReult = ValidateApiResult(result);
                if (validateReult == null)
                {
                    return(RedirectToAction(nameof(GetAllAccounts)));
                }
                return(validateReult);
            }
        }
コード例 #27
0
 public ActionResult AddAccount(AddAccountViewModel model)
 {
     if (ModelState.IsValid)
     {
         var acc = new AccountDTO()
         {
             Name          = model.Name,
             CreditCardId  = model.SelectedCreditCardId,
             UserProfileId = User.Identity.GetUserId()
         };
         AccountService.Create(acc);
         return(RedirectToAction("Accounts"));
     }
     else
     {
         var cards = CardService.FindUserCards(User.Identity.GetUserId()).ToList();
         model.Cards = new SelectList(cards, "Id", "Number");
         return(View(model));
     }
 }
コード例 #28
0
        public AddBankAccountPage()
        {
            BindingContext = new AddAccountViewModel(Navigation);

            var addBankAccountUrl  = String.Format("{0}/bank_account/new?token={1}", App.AppEnv[App.CurrentAppEnv], App.Token);
            var addBankAccountView = new WebView
            {
                Source = new UrlWebViewSource
                {
                    Url = addBankAccountUrl,
                },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var closeImage = new Image
            {
                Source            = ImageSource.FromUri(new Uri("https://s3.amazonaws.com/doloco_images/assets/cross66_64.png")),
                Aspect            = Aspect.AspectFit,
                AnchorX           = 0,
                HorizontalOptions = LayoutOptions.End
            };

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += async(s, e) =>
            {
                await Navigation.PopModalAsync();
            };
            closeImage.GestureRecognizers.Add(tapGestureRecognizer);

            this.BackgroundColor = Color.White;

            Content = new StackLayout
            {
                Children =
                {
                    closeImage,
                    addBankAccountView
                }
            };
        }
コード例 #29
0
        public async Task <ActionResult> Add([Bind(Include = "RoleName, Email, DisplayName")] AddAccountViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.DisplayName, Email = model.Email
                };
                var password = Membership.GeneratePassword(8, 1);
                var result   = await UserManager.CreateAsync(user, password);

                if (result.Succeeded)
                {
                    // Assign user role
                    UserManager.AddToRole(user.Id, model.RoleName);

                    // For more information on how to enable account confirmation
                    // and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account",
                                                 new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    var msgSubject = Resources.Resources.ConfirmAccountSubject;
                    var msgBody    = string.Format(
                        "{0}{1}<br/>{2}: <a href=\"{3}\">{4}</a>",
                        Resources.Resources.InitialPassword,
                        password,
                        Resources.Resources.ConfirmAccountPrompt,
                        callbackUrl,
                        Resources.Resources.Link);
                    await UserManager.SendEmailAsync(user.Id, msgSubject, msgBody);

                    return(RedirectToAction("Index"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(string.Format("Add{0}", model.RoleName), model));
        }
コード例 #30
0
        public async Task <HttpResponseMessage> Register(AddAccountViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Invalid data sent"));
            }


            IdentityResult result = null;

            using (var context = db)
            {
                var roleStore   = new RoleStore <IdentityRole>(context);
                var roleManager = new RoleManager <IdentityRole>(roleStore);

                var userStore   = new UserStore <ApplicationUser>(context);
                var userManager = new UserManager <ApplicationUser>(userStore);

                var user = new Account {
                    UserName = model.Email, Email = model.Email, Status = "registered", PhoneNumber2 = model.PhoneNumber2, Designation = model.Designation, Address = model.Address, FirstName = model.FirstName
                };

                if (userManager.FindByEmail(user.Email) == null)
                {
                    // Create the user and add it to the Staff role
                    result = await userManager.CreateAsync(user, model.Password);

                    await userManager.AddToRoleAsync(user.Id, "Staff");
                }
            }

            if (result == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "An account with the same email already exist."));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, "Account created successfully"));
        }