コード例 #1
0
        public async void AddUser_ToEmptyDbTable_AddedUserEqualExpectedUser()
        {
            // arrange
            var expected = GetRegistrationModel();

            // act
            await logic.AddDataModelAsync(expected);

            // assert
            var actualUserData = await fixture.dbAuth.UserData.FirstOrDefaultAsync(i => i.Login == expected.Login);

            var actualUserAuth = await fixture.dbAuth.UserAuth.FirstOrDefaultAsync(i => i.Login == expected.Login);

            Assert.Equal(expected.Login, actualUserData.Login);
            Assert.Equal(expected.RoleName, actualUserData.RoleName);
            Assert.Equal(expected.Login, actualUserAuth.Login);
        }
コード例 #2
0
        public async Task <IActionResult> AddSingleItem(RegistrationModel model)
        {
            var statusMessage = await logicValidation.CheckAddSingleDataModelAsync(model.Login, model.RoleName);

            if (statusMessage.IsCompleted)
            {
                var user = await logic.AddDataModelAsync(model);

                await logProvider.AddToLogAsync($"Added new user (Login: {user.Login}).");

                return(RedirectToRoute(UserManagmentRouting.Index));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }