diff --git a/Sledgemapper.Api/Controllers/SessionController.cs b/Sledgemapper.Api/Controllers/SessionController.cs
index d27d699..b644773 100644
--- a/Sledgemapper.Api/Controllers/SessionController.cs
+++ b/Sledgemapper.Api/Controllers/SessionController.cs
@@ -49,37 +49,35 @@ namespace Sledgemapper.Api.Controllers
public async Task Post(string sessionName, [FromBody] Overlay overlay)
{
var userId = int.Parse(HttpContext.User.Identity.Name);
- await _mediator.Publish(new NewOverlayCommand(sessionName, overlay, userId));
+ await _mediator.Send(new NewOverlayCommand(sessionName, overlay, userId));
}
[HttpPost("wall")]
public async Task Post(string sessionName, [FromBody] Wall wall)
{
var userId = int.Parse(HttpContext.User.Identity.Name);
- await _mediator.Publish(new NewWallCommand(sessionName, wall, userId));
+ await _mediator.Send(new NewWallCommand(sessionName, wall, userId));
}
[HttpDelete("tile")]
public async Task Delete(string sessionName, [FromBody] Tile tile)
{
var userId = int.Parse(HttpContext.User.Identity.Name);
- await _mediator.Publish(new DeleteTileCommand(sessionName, tile, userId));
+ await _mediator.Send(new DeleteTileCommand(sessionName, tile, userId));
}
[HttpDelete("overlay")]
public async Task Delete(string sessionName, [FromBody] Overlay overlay)
{
var userId = int.Parse(HttpContext.User.Identity.Name);
- await _mediator.Publish(new DeleteOverlayCommand(sessionName, overlay, userId));
+ await _mediator.Send(new DeleteOverlayCommand(sessionName, overlay, userId));
}
[HttpDelete("wall")]
public async Task Delete(string sessionName, [FromBody] Wall wall)
{
var userId = int.Parse(HttpContext.User.Identity.Name);
- await _mediator.Publish(new DeleteWallCommand(sessionName, wall, userId));
+ await _mediator.Send(new DeleteWallCommand(sessionName, wall, userId));
}
-
-
}
}
\ No newline at end of file
diff --git a/Sledgemapper.Api/LocalDatabase.db b/Sledgemapper.Api/LocalDatabase.db
index 89c527f..e8db702 100644
Binary files a/Sledgemapper.Api/LocalDatabase.db and b/Sledgemapper.Api/LocalDatabase.db differ
diff --git a/Sledgemapper.Api/Sledgemapper.Api.csproj b/Sledgemapper.Api/Sledgemapper.Api.csproj
index bf9b406..be04316 100644
--- a/Sledgemapper.Api/Sledgemapper.Api.csproj
+++ b/Sledgemapper.Api/Sledgemapper.Api.csproj
@@ -5,18 +5,18 @@
-
-
+
+
-
-
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
-
-
+
+
+
diff --git a/Sledgemapper.Api/sledgemapper.db b/Sledgemapper.Api/sledgemapper.db
index fbb3f89..5531a39 100644
Binary files a/Sledgemapper.Api/sledgemapper.db and b/Sledgemapper.Api/sledgemapper.db differ
diff --git a/Sledgemapper/Sledgemapper.cs b/Sledgemapper/Sledgemapper.cs
index 0ac6e41..0651f2e 100644
--- a/Sledgemapper/Sledgemapper.cs
+++ b/Sledgemapper/Sledgemapper.cs
@@ -293,7 +293,14 @@ namespace Sledgemapper
_spriteBatch.End();
- _desktop?.Render();
+ try
+ {
+ _desktop?.Render();
+ }
+ catch
+ {
+ System.Console.WriteLine("Desktop render error");
+ }
base.Draw(gameTime);
}
@@ -556,7 +563,8 @@ namespace Sledgemapper
private async void OnButtonLoginClick(object sender, EventArgs e)
{
- Container container = ((TextButton)sender).Parent;
+ var button = ((TextButton)sender);
+ Container container = button.Parent;
while (!(container is Window))
{
container = container.Parent;
@@ -564,23 +572,30 @@ namespace Sledgemapper
var localWindow = (Window)container;
var localContent = localWindow.Content as LoginRegisterWindow;
+
+ if (!button.Enabled)
+ {
+ return;
+ }
+
var isValid = true;
isValid &= ValidateTextbox(localContent.TxtEmail);
isValid &= ValidateTextbox(localContent.TxtPassword);
if (!isValid)
{
- localContent.LblLoginError.Text="Username or password is not valid";
- localContent.LblLoginError.Visible=true;
-
+ localContent.LblLoginError.Text = "Username or password is not valid";
+ localContent.LblLoginError.Visible = true;
+
return;
}
var successful = false;
try
{
- localContent.LblLoginError.Text="";
- localContent.LblLoginError.Visible=false;
+ button.Text = "Wait...";
+ localContent.LblLoginError.Text = "";
+ localContent.LblLoginError.Visible = false;
_authResponse = await _communicationManager.Login(new AuthenticateModel
{
Username = localContent.TxtEmail.Text,
@@ -588,11 +603,20 @@ namespace Sledgemapper
});
successful = _authResponse != null;
}
+ catch (Refit.ApiException refitException)
+ {
+ localContent.LblLoginError.Text = refitException.Content;
+ localContent.LblLoginError.Visible = true;
+ }
catch (Exception ex)
{
- Console.WriteLine(ex.Message);
- localContent.LblLoginError.Text=ex.Message;
- localContent.LblLoginError.Visible=true;
+ localContent.LblLoginError.Text = "Can't connect to the server";
+ localContent.LblLoginError.Visible = true;
+ }
+ finally
+ {
+ button.Enabled = true;
+ button.Text = "Login";
}
if (successful)
@@ -608,7 +632,8 @@ namespace Sledgemapper
private async void OnButtonRegisterClick(object sender, EventArgs e)
{
- Container container = ((TextButton)sender).Parent;
+ var button = ((TextButton)sender);
+ Container container = button.Parent;
while (!(container is Window))
{
container = container.Parent;
@@ -616,6 +641,12 @@ namespace Sledgemapper
var localWindow = (Window)container;
var localContent = localWindow.Content as LoginRegisterWindow;
+
+ if (!button.Enabled)
+ {
+ return;
+ }
+
var isValid = true;
isValid &= ValidateTextbox(localContent.TxtEmail);
isValid &= ValidateTextbox(localContent.TxtPassword);
@@ -625,12 +656,18 @@ namespace Sledgemapper
if (!isValid)
{
+ localContent.LblLoginError.Text = "Please complete all the fields";
+ localContent.LblLoginError.Visible = true;
return;
}
var successful = false;
try
{
+ button.Text = "Wait...";
+ localContent.LblLoginError.Text = "";
+ localContent.LblLoginError.Visible = false;
+
var result = await _communicationManager.Register(new RegisterModel
{
Username = localContent.TxtEmail.Text,
@@ -649,9 +686,20 @@ namespace Sledgemapper
successful = true;
}
}
+ catch (Refit.ApiException refitException)
+ {
+ localContent.LblLoginError.Text = refitException.Content;
+ localContent.LblLoginError.Visible = true;
+ }
catch (Exception ex)
{
- Console.WriteLine(ex.Message);
+ localContent.LblLoginError.Text = "Can't connect to the server";
+ localContent.LblLoginError.Visible = true;
+ }
+ finally
+ {
+ button.Enabled = true;
+ button.Text = "Register";
}
if (successful)
{
@@ -659,6 +707,9 @@ namespace Sledgemapper
_mainWidget.MenuConnectJoin.Enabled = true;
_mainWidget.MenuConnectSync.Enabled = true;
_mainWidget.MenuConnectUpload.Enabled = true;
+
+ _mainWidget.lblUsername.Text = $"{_authResponse.Username} - {_authResponse.Initials}";
+
localWindow.Close();
}
}
@@ -856,7 +907,11 @@ namespace Sledgemapper
var valid = !string.IsNullOrWhiteSpace(textBox.Text);
if (!valid)
{
- textBox.Background = new SolidBrush(Color.PaleVioletRed);
+ textBox.Background = new SolidBrush(Color.Red);
+ }
+ else
+ {
+ textBox.Background = new SolidBrush(new Color(51, 51, 51)); ;
}
return valid;
}
diff --git a/Sledgemapper/Sledgemapper.csproj b/Sledgemapper/Sledgemapper.csproj
index 6b2424c..a475937 100644
--- a/Sledgemapper/Sledgemapper.csproj
+++ b/Sledgemapper/Sledgemapper.csproj
@@ -39,9 +39,9 @@
- 3.1.9
+ 5.0.0
-
+
diff --git a/Sledgemapper/UI/LoginRegisterWindow.Generated.cs b/Sledgemapper/UI/LoginRegisterWindow.Generated.cs
index 4fbfe7f..a207ff8 100644
--- a/Sledgemapper/UI/LoginRegisterWindow.Generated.cs
+++ b/Sledgemapper/UI/LoginRegisterWindow.Generated.cs
@@ -1,4 +1,4 @@
-/* Generated by MyraPad at 18/11/2020 16:11:22 */
+/* Generated by MyraPad at 19/11/2020 11:58:09 */
using Myra.Graphics2D;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI;
@@ -32,7 +32,7 @@ namespace Sledgemapper.UI
horizontalStackPanel1.Widgets.Add(RdoRegister);
var label1 = new Label();
- label1.Text = "Email";
+ label1.Text = "Username";
var label2 = new Label();
label2.Text = "Password";
diff --git a/Sledgemapper/UI/loginwindow.xml b/Sledgemapper/UI/loginwindow.xml
index 4d5c13b..921ac99 100644
--- a/Sledgemapper/UI/loginwindow.xml
+++ b/Sledgemapper/UI/loginwindow.xml
@@ -10,7 +10,7 @@
-
+