Snackbar meg ilyesmik
This commit is contained in:
@@ -11,10 +11,14 @@ namespace WorkFlowCheck.MAUI.Pages.CheckList;
|
|||||||
public partial class CheckListWorkPage : ContentPage
|
public partial class CheckListWorkPage : ContentPage
|
||||||
{
|
{
|
||||||
private readonly ICheckListService _checkListService;
|
private readonly ICheckListService _checkListService;
|
||||||
|
private readonly ISyncService _syncService;
|
||||||
|
|
||||||
private string _checkPointCode;
|
private string _checkPointCode;
|
||||||
private int _checkListHeaderId;
|
private int _checkListHeaderId;
|
||||||
private UserDTO _userDTO;
|
private UserDTO _userDTO;
|
||||||
private bool _isLoading;
|
private bool _isLoading;
|
||||||
|
|
||||||
|
|
||||||
public bool IsLoading
|
public bool IsLoading
|
||||||
{
|
{
|
||||||
get => _isLoading;
|
get => _isLoading;
|
||||||
@@ -35,6 +39,7 @@ public partial class CheckListWorkPage : ContentPage
|
|||||||
_checkPointCode = checkPointCode;
|
_checkPointCode = checkPointCode;
|
||||||
_checkListHeaderId = checkListHeaderId;
|
_checkListHeaderId = checkListHeaderId;
|
||||||
_checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>();
|
_checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>();
|
||||||
|
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
|
||||||
_userDTO = MauiProgram.ServiceProvider.GetRequiredService<IUserService>().GetCurrentUser();
|
_userDTO = MauiProgram.ServiceProvider.GetRequiredService<IUserService>().GetCurrentUser();
|
||||||
|
|
||||||
SaveCommand = new Command(OnSave);
|
SaveCommand = new Command(OnSave);
|
||||||
@@ -43,7 +48,17 @@ public partial class CheckListWorkPage : ContentPage
|
|||||||
|
|
||||||
private async void OnSend()
|
private async void OnSend()
|
||||||
{
|
{
|
||||||
|
IsLoading = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OnSave();
|
||||||
|
await _syncService.SyncCheckListHeaderUp(_checkListHeaderId);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await Application.Current.MainPage.DisplayAlert("Hiba", ex.Message, "OK");
|
||||||
|
}
|
||||||
|
IsLoading = false;
|
||||||
}
|
}
|
||||||
private async void OnSave()
|
private async void OnSave()
|
||||||
{
|
{
|
||||||
@@ -74,7 +89,6 @@ public partial class CheckListWorkPage : ContentPage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override async void OnAppearing()
|
protected override async void OnAppearing()
|
||||||
{
|
{
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
using CommunityToolkit.Maui.Alerts;
|
||||||
|
using CommunityToolkit.Maui.Core;
|
||||||
|
using System.Drawing;
|
||||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI.Pages.Security;
|
namespace WorkFlowCheck.MAUI.Pages.Security;
|
||||||
|
|
||||||
public partial class LoginPage : ContentPage
|
public partial class LoginPage : ContentPage
|
||||||
{
|
{
|
||||||
private IUserService _userService;
|
private IUserService _userService;
|
||||||
private ISyncService _syncService;
|
private ISyncService _syncService;
|
||||||
public LoginPage()
|
public LoginPage()
|
||||||
{
|
{
|
||||||
@@ -36,7 +39,25 @@ public partial class LoginPage : ContentPage
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await DisplayAlert("Error", "Invalid login credentials.", "OK");
|
|
||||||
|
var visualOptions = new SnackbarOptions
|
||||||
|
{
|
||||||
|
ActionButtonTextColor = Colors.Yellow,
|
||||||
|
CornerRadius = new CornerRadius(10),
|
||||||
|
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
|
||||||
|
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
|
||||||
|
TextColor=Colors.Yellow
|
||||||
|
|
||||||
|
};
|
||||||
|
var snackbar = Snackbar.Make(
|
||||||
|
"Invalid login credentials.",
|
||||||
|
duration: TimeSpan.FromSeconds(10),
|
||||||
|
action: () => Console.WriteLine("Snackbar dismissed"),
|
||||||
|
actionButtonText: "OK",
|
||||||
|
visualOptions: visualOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await snackbar.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
@@ -163,7 +163,10 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
if (checkListRow != null)
|
if (checkListRow != null)
|
||||||
{
|
{
|
||||||
checkListRow.Answer = checkListRowDTO.Answer;
|
checkListRow.Answer = checkListRowDTO.Answer;
|
||||||
checkListRow.Photo = checkListRowDTO.Photo;
|
if (checkListRowDTO.Photo != null && checkListRowDTO.Photo.Length > 0)
|
||||||
|
{
|
||||||
|
checkListRow.Photo = checkListRowDTO.Photo;
|
||||||
|
}
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using WorkFlowCheck.Common.DTO;
|
||||||
|
|
||||||
namespace WorkFlowCheck.MAUI.Services.Interfaces
|
namespace WorkFlowCheck.MAUI.Services.Interfaces
|
||||||
{
|
{
|
||||||
@@ -14,6 +15,6 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
|||||||
Task SyncLocations();
|
Task SyncLocations();
|
||||||
Task SyncEquipments();
|
Task SyncEquipments();
|
||||||
|
|
||||||
|
Task SyncCheckListHeaderUp(int Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,5 +254,33 @@ namespace WorkFlowCheck.MAUI.Services
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task SyncCheckListHeaderUp(int Id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PrepareAuthenticatedRequestAsync();
|
||||||
|
|
||||||
|
var checkListHeader = await _dbContext.CheckListHeaders
|
||||||
|
.Include(i => i.CheckListRows)
|
||||||
|
.AsNoTracking()
|
||||||
|
.ToListAsync();
|
||||||
|
var checkListHeaderDTO = _mapper.Map<CheckListHeaderDTO>(checkListHeader);
|
||||||
|
|
||||||
|
|
||||||
|
var endpoint = $"{_httpClient.BaseAddress}api/Sync/UpdateCheckListHeader";
|
||||||
|
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, checkListHeaderDTO))
|
||||||
|
{
|
||||||
|
httpResponseMessage.EnsureSuccessStatusCode();
|
||||||
|
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||||
|
var response = JsonConvert.DeserializeObject<ApiResponseDTO<CheckListHeaderDTO>>(jsonString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Hiba visszaadása
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user