diff --git a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml
index a71f3bc..4a11819 100644
--- a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml
+++ b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml
@@ -10,6 +10,7 @@
@@ -33,7 +34,22 @@
-
+
+
+
+
@@ -41,17 +57,25 @@
-
+
-
-
+
-
-
+
+
+
-
@@ -69,7 +93,10 @@
-
+
@@ -88,7 +115,22 @@
-
+
+
+
+
@@ -202,5 +244,6 @@
PI_N_Template="{StaticResource PI_N_Template}"
I_PN_Template="{StaticResource I_PN_Template}"
V_Template="{StaticResource V_Template}"/>
+
\ No newline at end of file
diff --git a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml.cs b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml.cs
index 233e006..8ee1feb 100644
--- a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml.cs
+++ b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml.cs
@@ -1,6 +1,10 @@
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Services.Interfaces;
using Microsoft.Maui.Controls;
+using System.Windows.Input;
+using System.Globalization;
+using DevExpress.Data.Helpers;
+using System.Collections.ObjectModel;
namespace WorkFlowCheck.MAUI.Pages.CheckList;
@@ -11,6 +15,8 @@ public partial class CheckListWorkPage : ContentPage
private int _checkListHeaderId;
private UserDTO _userDTO;
+ public ObservableCollection CheckListRows { get; set; } = new ObservableCollection();
+ public ICommand CreatePhoto { get; set; }
public CheckListWorkPage(int checkListHeaderId, string checkPointCode)
{
@@ -23,14 +29,47 @@ public partial class CheckListWorkPage : ContentPage
protected override async void OnAppearing()
{
base.OnAppearing();
- BindingContext = this;
-
+ CreatePhoto = new Command(OnTakePhoto);
await LoadCheckPointCheckListRows();
+ BindingContext = this;
}
+ private async void OnTakePhoto(CheckListRowDTO checkListRowDTO)
+ {
+ try
+ {
+ if (MediaPicker.IsCaptureSupported)
+ {
+ var photo = await MediaPicker.CapturePhotoAsync();
+ if (photo != null)
+ {
+ using var stream = await photo.OpenReadAsync();
+ using var ms = new MemoryStream();
+ await stream.CopyToAsync(ms);
+ byte[] photoBytes = ms.ToArray();
+ checkListRowDTO.Photo = photoBytes;
+ await _checkListService.UpdateCheckListRow(checkListRowDTO);
+ await LoadCheckPointCheckListRows();
+ }
+ }
+ else
+ {
+ Console.WriteLine("A fényképezés nem támogatott ezen az eszközön.");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Hiba történt a fényképezés közben: {ex.Message}");
+ }
+ }
private async Task LoadCheckPointCheckListRows()
{
- CheckPointCheckListRows.ItemsSource = await _checkListService.GetCheckListRowsByCheckPointCode(_userDTO.Id, _checkListHeaderId, _checkPointCode);
+ CheckListRows.Clear();
+ var checkListRowDTOs = await _checkListService.GetCheckListRowsByCheckPointCode(_userDTO.Id, _checkListHeaderId, _checkPointCode);
+ foreach (var item in checkListRowDTOs)
+ {
+ CheckListRows.Add(item);
+ }
}
}
public class BindableRadioButton : RadioButton
@@ -51,4 +90,20 @@ public class BindableRadioButton : RadioButton
radioButton.GroupName = newGroupName;
}
}
-}
\ No newline at end of file
+}
+public class ByteArrayToImageSourceConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is byte[] bytes && bytes.Length > 0)
+ {
+ return ImageSource.FromStream(() => new MemoryStream(bytes));
+ }
+ return null;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+}
diff --git a/src/WorkFlowCheck.MAUI/Services/CheckListService.cs b/src/WorkFlowCheck.MAUI/Services/CheckListService.cs
index fe6ea45..e6df8e2 100644
--- a/src/WorkFlowCheck.MAUI/Services/CheckListService.cs
+++ b/src/WorkFlowCheck.MAUI/Services/CheckListService.cs
@@ -138,5 +138,23 @@ namespace WorkFlowCheck.MAUI.Services
return retVal;
}
+
+ public async Task UpdateCheckListRow(CheckListRowDTO checkListRowDTO)
+ {
+ var retVal = checkListRowDTO;
+ try
+ {
+ var checkListRow = await _dbContext.CheckListRows.Where(w => w.Id == checkListRowDTO.Id).FirstOrDefaultAsync();
+ if (checkListRow != null)
+ {
+ checkListRow.Photo = checkListRowDTO.Photo;
+ await _dbContext.SaveChangesAsync();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ return retVal;
+ }
}
}
diff --git a/src/WorkFlowCheck.MAUI/Services/Interfaces/ICheckListService.cs b/src/WorkFlowCheck.MAUI/Services/Interfaces/ICheckListService.cs
index 33d15a4..799749f 100644
--- a/src/WorkFlowCheck.MAUI/Services/Interfaces/ICheckListService.cs
+++ b/src/WorkFlowCheck.MAUI/Services/Interfaces/ICheckListService.cs
@@ -16,5 +16,6 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
Task> GetCheckLists(int userId);
Task> GetCheckListTemplates(int userId);
Task> GetCheckListRowsByCheckPointCode(int userId, int checkListHeaderId, string checkPointCode);
+ Task UpdateCheckListRow(CheckListRowDTO checkListRowDTO);
}
}