Esempio n. 1
0
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            UserDto userRegister = new UserDto();

            userRegister.UserName = txtuname.Text;
            userRegister.Password = txtpsw.Text;
            userRegister.Name     = txtname.Text;
            userRegister.MobileNo = txtmobile.Text;
            userRegister.EmailId  = txtemail.Text;


            UserService Service = new UserServiceImpl();
            bool        insert  = Service.AddUser(userRegister);

            if (insert)
            {
                //lblstatus.Text = "<b style='color:red'>User detailes  has been inserted successfully!!!</b>";
                ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('User detailes  has been instantiate successfully.')</script>");
                txtuname.Text  = string.Empty;
                txtpsw.Text    = string.Empty;
                txtname.Text   = string.Empty;
                txtmobile.Text = string.Empty;
                txtemail.Text  = string.Empty;
            }
            else
            {
                //lblstatus.Text = "<b style='color:red'>User detailes insertion failed!!!</b>";
                ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('User detailes insertion failed.')</script>");
            }
            //Response.Redirect("~/Login.aspx");
        }
Esempio n. 2
0
        public void ErrorCreatingUserWithSameUserNameTest()
        {
            Role role = new Role(Roles.ADMINISTRATOR);
            User user = new User("Carlos", "Perez", "Carlitos", 091234567, "Password", role);

            UserDTO userDTO = new UserDTO();

            userDTO.Name     = "Carlos";
            userDTO.LastName = "Perez";
            userDTO.UserName = "******";
            userDTO.Phone    = 091234567;
            userDTO.Password = "******";
            userDTO.Role     = "Administrador";

            var mockUserDAO = new Mock <UserDAO>();

            mockUserDAO.Setup(us => us.FindUserByUserName("Carlitos")).Returns(userDTO);

            var userService = new UserServiceImpl(mockUserDAO.Object);

            userService.AddUser(userDTO);
        }