public async Task <UserDto> Handle(CreateUserCommand request, CancellationToken cancellationToken) { var input = request.Data.Attributes; var user = new Users_() { name = input.name, username = input.username, email = input.email, password = input.password, address = input.address }; _context.UsersData.Add(user); await _context.SaveChangesAsync(); var user1 = _context.UsersData.First(x => x.username == request.Data.Attributes.username); var target = new Target() { Id = user.id, Email_destination = user.email }; var command = new NotifInput() { Title = "rabbit - test", Message = "this is only testing", Type = "email", From = 123456, Targets = new List <Target>() { target } }; var attributes = new Attribute <NotifInput>() { Attributes = command }; var httpContent = new CommandDTO <NotifInput>() { Data = attributes }; var jsonObject = JsonConvert.SerializeObject(httpContent); var content = new StringContent(jsonObject, Encoding.UTF8, "application/json"); await client.PostAsync("http://localhost:5800/api/notification", content); return(new UserDto { message = "Success add a user data", success = true }); }
private void Registerbtn_Click(object sender, EventArgs e) { string fname = txtFirstname.Text; string suname = txtSurname.Text; string phone = txtPhone.Text; string pass = txtPassword.Text; string confirmPass = txtConPass.Text; string[] myArr = new string[] { fname, suname, phone, pass, confirmPass }; if (Utilities.isEmpty(myArr)) { if (pass == confirmPass) { Users_ selectedUser = db.Users_.FirstOrDefault(u => u.Firstname == fname); if (selectedUser == null) { int roleid = db.Roles.FirstOrDefault(x => x.Name == "User").ID; Users_ user = new Users_(); user.Firstname = fname; user.Surname = suname; user.Phone = phone; user.Password = pass.HashMe(); user.RoleID = roleid; db.Users_.Add(user); db.SaveChanges(); MessageBox.Show("User created successfully!", "success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { lblError.Text = "Firstname already exist!"; lblError.Visible = true; } } else { lblError.Text = "password and confirm is not the same"; lblError.Visible = true; } } else { lblError.Text = "Please,all the fiel!"; lblError.Visible = true; } }
public async Task <UserDto> Handle(CreateUserCommand request, CancellationToken cancellationToken) { var user = new Users_() { 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.UsersData.Add(user); await _context.SaveChangesAsync(cancellationToken); var user1 = _context.UsersData.First(x => x.username == request.Data.Attributes.username); var target = new Target() { Id = user.id, Email_destination = user.email }; var client = new HttpClient(); var command = new NotifInput() { Title = "rabbit-test", Message = "this is only testing", Type = "email", From = 98780, Target = new List <Target>() { target } }; var attributes = new Attribute <NotifInput>() { Attributes = command }; var httpContent = new CommandDTO <NotifInput>() { Data = attributes }; var jsonObject = JsonConvert.SerializeObject(httpContent); //var content = new StringContent(jsonObject, Encoding.UTF8, "application/json"); //await client.PostAsync("http://localhost:5800/api/notification", content); var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.ExchangeDeclare(exchange: "halopakpos", "fanout"); channel.QueueDeclare(queue: "pakpos", durable: true, exclusive: false, autoDelete: false, arguments: null); channel.QueueBind("pakpos", "halopakpos", routingKey: ""); var body = Encoding.UTF8.GetBytes(jsonObject); var properties = channel.CreateBasicProperties(); properties.Persistent = true; channel.BasicPublish(exchange: "halopakpos", routingKey: "", basicProperties: null, body: body); Console.WriteLine("Message has sent"); } return(new UserDto { message = "a user has been added.", success = true }); }
public Rezervation_Form(Users_ user) { activeUser_ = user; InitializeComponent(); }
private void cmbUser_SelectedIndexChanged(object sender, EventArgs e) { string usname = cmbUser.Text; selectedUser = db.Users_.FirstOrDefault(u => u.Firstname == usname); }
public AdminForm(Users_ user) { activeUser_ = user; InitializeComponent(); }
private void btnLogIn_Click(object sender, EventArgs e) { string fname = txtFirstname.Text; string suname = txtSurname.Text; string pass = txtPassword.Text; if (Utilities.isEmpty(new string[] { fname, suname, pass })) { Users_ selectedUser = db.Users_.FirstOrDefault(c => c.Firstname == fname); if (selectedUser != null) { if (selectedUser.Password == pass.HashMe()) { if (ckRemember.Checked) { Properties.Settings.Default.firstname = fname; Properties.Settings.Default.surname = suname; Properties.Settings.Default.password = pass; Properties.Settings.Default.isChecked = true; Properties.Settings.Default.Save(); } else { Properties.Settings.Default.firstname = ""; Properties.Settings.Default.surname = ""; Properties.Settings.Default.password = ""; Properties.Settings.Default.isChecked = false; Properties.Settings.Default.Save(); } if (selectedUser.RoleID == 1) { this.Hide(); var ds = new Rezervation_Form(selectedUser); ds.FormClosed += (s, args) => this.Close(); ds.ShowDialog(); } if (selectedUser.RoleID == 2) { this.Hide(); var ds = new AdminForm(selectedUser); ds.FormClosed += (s, args) => this.Close(); ds.ShowDialog(); } } else { lblError.Text = "password doesn't correct!"; lblError.Visible = true; } } else { lblError.Text = "username doesn't correct"; lblError.Visible = true; } } else { lblError.Text = "Please,all the fiel"; lblError.Visible = true; } }