Пример #1
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            UserService userService = new UserService();
            User        user        = new User
            {
                UserName = txtUserName.Text,
                Password = txtPassword.Text,
                Audit    = chkAudit.Checked
            };
            int id;

            if (int.TryParse(Request["id"], out id))
            {
                user.UserId = id;
                userService.Update(user);
            }
            else
            {
                User            userAdded       = userService.Create(user);
                UserInfoService userInfoService = new UserInfoService();
                userInfoService.Create(new UserInfo {
                    UserId = userAdded.UserId
                });
            }

            PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
        }
Пример #2
0
        public void Create()
        {
            //Arrange
            var userInfo = new UserInfo()
            {
                Id = 1
            };
            var userInfoRepository = new MockIRepository <UserInfo>()
                                     .MockCreate(userInfo);
            var userInfoService = new UserInfoService(userInfoRepository.Object);

            //Act
            var createdUserInfo = userInfoService.Create(userInfo);

            //Assert
            Assert.IsNotNull(createdUserInfo);
        }
Пример #3
0
        protected void btnRegist_Click(object sender, EventArgs e)
        {
            UserService     user            = new UserService();
            UserInfoService userInfoService = new UserInfoService();

            if (user.CheckUserNameForRegist(txtUserName.Text.Trim()))
            {
                user.Add(new User
                {
                    UserName = txtUserName.Text.Trim(),
                    Password = txtPwd.Text,
                    Audit    = false
                });
                int userId = user.GetUserByUserName(txtUserName.Text.Trim()).UserId;
                userInfoService.Create(new UserInfo {
                    UserId = userId
                });
            }
        }
Пример #4
0
 public void Create(User user)
 {
     _userService.Create(user);
 }
        public ActionResult <User_Info> Create(User_Info user)
        {
            var temp = _userInfoService.Create(user);

            return(temp);
        }
Пример #6
0
        public ActionResult <UserInfo> Create([FromBody] UserInfo userInfo)
        {
            _userInfoService.Create(userInfo);

            return(CreatedAtRoute("GetUserInfo", new { id = userInfo.Id.ToString() }, userInfo));
        }