krimskrams

This commit is contained in:
DaddyPig 2024-06-11 10:16:22 +02:00
parent 4f849171c9
commit 7b8355972b
3 changed files with 30 additions and 0 deletions

View File

@ -113,6 +113,8 @@
Background="#FF323134" Background="#FF323134"
Foreground="White" Foreground="White"
SelectionBrush="#FF6332A0" KeyDown="messageBOX_KeyDown"/> SelectionBrush="#FF6332A0" KeyDown="messageBOX_KeyDown"/>
<Button x:Name="weiterbutton" Click="send_Click" Content="Weiter" Foreground="White" Background="#FF6332A0" BorderThickness="0" Margin="831,643,44,11" BorderBrush="{x:Null}" Style="{StaticResource NoHoverButtonStyle}" RenderTransformOrigin="0.279,0.633"/>
</Grid> </Grid>

View File

@ -139,6 +139,31 @@ namespace bib_talk
} }
} }
} }
private async void send_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(messageBOX.Text))
{
var message = new MessageDto
{
Username = loggedinUser,
Message = messageBOX.Text,
Timestamp = DateTime.Now,
};
using (var client = new HttpClient())
{
var json = JsonConvert.SerializeObject(message);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/messages/send", content);
if (response.IsSuccessStatusCode)
{
messageBOX.Clear();
LoadMessages(); // Reload messages after sending
}
}
}
}
public class Message public class Message
{ {

View File

@ -52,6 +52,9 @@ namespace bib_talk
if (ValidateRegistration()) if (ValidateRegistration())
{ {
RegisterServer(); RegisterServer();
Login login = new Login();
login.Show();
this.Close();
} }
} }
else else