public async Task <CreateUserCommandDto> Handle(CreateUserCommand request, CancellationToken cancellation)
        {
            var us = new UserEn
            {
                Name     = request.Data.Attributes.Name,
                Username = request.Data.Attributes.Username,
                Email    = request.Data.Attributes.Email,
                Password = request.Data.Attributes.Password,
                Address  = request.Data.Attributes.Address
            };

            _context.Users.Add(us);
            await _context.SaveChangesAsync(cancellation);

            var user   = _context.Users.First(i => i.Username == request.Data.Attributes.Username);
            var target = new Target()
            {
                Id = user.Id, EmailDestination = user.Email
            };

            var po = new UserNo()
            {
                Title   = "This is the title of the massage",
                Message = "The massage is nothing, just this",
                Type    = "Email",
                From    = 1,
                Targets = new List <Target>()
                {
                    target
                }
            };

            var attributes = new Data <UserNo>()
            {
                Attributes = po
            };
            var httpContent = new RequestData <UserNo>()
            {
                Data = attributes
            };
            var convert = JsonConvert.SerializeObject(httpContent);
            var data    = new StringContent(convert, Encoding.UTF8, "application/json");

            //await client.PostAsync("http://notificationservice/notification", content);

            return(new CreateUserCommandDto
            {
                Success = true,
                Message = "User successfully created"
            });
        }
Beispiel #2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            TextBox txtUserName = LoginView1.FindControl("txtUserName") as TextBox;
            TextBox txtPassword = LoginView1.FindControl("txtPassword") as TextBox;
            Label   lbMessage   = LoginView1.FindControl("lbMessage") as Label;

            string userName = txtUserName.Text;
            string password = txtPassword.Text;

            if (string.IsNullOrEmpty(userName))
            {
                lbMessage.Text = "账号不能为空!"; return;
            }
            if (string.IsNullOrEmpty(password))
            {
                lbMessage.Text = "密码不能为空!"; return;
            }

            LoginResult result = Login(userName, password);

            if (result == LoginResult.UserNotExist)
            {
                lbMessage.Text = "用户名不存在!"; return;
            }
            if (result == LoginResult.Enabeld)
            {
                lbMessage.Text = "账号已被停用!"; return;
            }
            if (result == LoginResult.PasswordWrong)
            {
                lbMessage.Text = "密码错误!"; return;
            }
            if (result == LoginResult.Success)
            {
                UserEn user = new UserEn();
                user.NAME = userName;
                string userData = "登录时间" + DateTime.Now.ToString();
                SetUserDataAndRedirect(userName, userData);
            }
        }
Beispiel #3
0
 // Inserts a user on the database
 public void InsertUser(UserEn u)
 {
 }
Beispiel #4
0
 // Deletes as user from the database
 public void DeletesUser(UserEn u)
 {
 }