Implemetato databese locale con EntityFramework
This commit is contained in:
@@ -8,7 +8,7 @@ public interface ISteupDataService
|
||||
Task Init();
|
||||
|
||||
List<PuntoVenditaDto> PuntiVenditaList { get; }
|
||||
InspectionPageState Inspection { get; set; }
|
||||
InspectionPageState InspectionPageState { get; set; }
|
||||
List<JtbFasiDto> Reparti { get; }
|
||||
List<StbActivityTypeDto> TipiAttività { get; }
|
||||
}
|
||||
@@ -3,16 +3,19 @@ using SteUp.Shared.Core.Data.Contracts;
|
||||
using SteUp.Shared.Core.Dto;
|
||||
using SteUp.Shared.Core.Dto.PageState;
|
||||
using SteUp.Shared.Core.Interface.IntegryApi;
|
||||
using SteUp.Shared.Core.Interface.LocalDb;
|
||||
|
||||
namespace SteUp.Shared.Core.Data;
|
||||
|
||||
public class SteupDataService(
|
||||
IIntegrySteupService integrySteupService,
|
||||
IUserSession userSession) : ISteupDataService
|
||||
IUserSession userSession,
|
||||
IDbInitializer dbInitializer) : ISteupDataService
|
||||
{
|
||||
public Task Init()
|
||||
public async Task Init()
|
||||
{
|
||||
return LoadDataAsync();
|
||||
await dbInitializer.InitializeAsync();
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
private async Task LoadDataAsync()
|
||||
@@ -24,7 +27,7 @@ public class SteupDataService(
|
||||
TipiAttività = await integrySteupService.RetrieveActivityType();
|
||||
}
|
||||
|
||||
public InspectionPageState Inspection { get; set; } = new();
|
||||
public InspectionPageState InspectionPageState { get; set; } = new();
|
||||
public List<PuntoVenditaDto> PuntiVenditaList { get; private set; } = [];
|
||||
public List<JtbFasiDto> Reparti { get; private set; } = [];
|
||||
public List<StbActivityTypeDto> TipiAttività { get; private set; } = [];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace SteUp.Shared.Core.Dto.PageState;
|
||||
using SteUp.Shared.Core.Entities;
|
||||
|
||||
namespace SteUp.Shared.Core.Dto.PageState;
|
||||
|
||||
public class InspectionPageState
|
||||
{
|
||||
public DateTime DateInspection {get; set;}
|
||||
|
||||
public PuntoVenditaDto? PuntoVendita {get; set;}
|
||||
public Ispezione Ispezione { get; set; } = new();
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace SteUp.Shared.Core.Dto;
|
||||
|
||||
public class SchedaDto
|
||||
{
|
||||
public JtbFasiDto? Reparto { get; set; }
|
||||
public string? ActivityTypeId { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public string? Responsabile { get; set; }
|
||||
public int Scadenza { get; set; } = 24;
|
||||
}
|
||||
17
SteUp.Shared/Core/Entities/Ispezione.cs
Normal file
17
SteUp.Shared/Core/Entities/Ispezione.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SteUp.Shared.Core.Enum;
|
||||
|
||||
namespace SteUp.Shared.Core.Entities;
|
||||
|
||||
public class Ispezione
|
||||
{
|
||||
[Required]
|
||||
public string CodMdep { get; set; } = string.Empty;
|
||||
public DateOnly Data { get; set; }
|
||||
[Required]
|
||||
public string Rilevatore { get; set; } = string.Empty;
|
||||
|
||||
public StatusEnum Stato { get; set; } = StatusEnum.InCorso;
|
||||
|
||||
public List<Scheda> Schede { get; set; } = [];
|
||||
}
|
||||
51
SteUp.Shared/Core/Entities/Scheda.cs
Normal file
51
SteUp.Shared/Core/Entities/Scheda.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using SteUp.Shared.Core.Dto;
|
||||
|
||||
namespace SteUp.Shared.Core.Entities;
|
||||
|
||||
public class Scheda
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string? CodJfas { get; set; }
|
||||
|
||||
[Required]
|
||||
public string CodMdep { get; set; } = string.Empty;
|
||||
public DateOnly Data { get; set; }
|
||||
[Required]
|
||||
public string Rilevatore { get; set; } = string.Empty;
|
||||
public Ispezione? Ispezione { get; set; }
|
||||
|
||||
public string? DescrizioneReparto { get; set; }
|
||||
public string? ActivityTypeId { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public string? Responsabile { get; set; }
|
||||
public int Scadenza { get; set; } = 24;
|
||||
|
||||
[NotMapped]
|
||||
public JtbFasiDto? Reparto
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_reparto == null && CodJfas != null)
|
||||
{
|
||||
_reparto = new JtbFasiDto
|
||||
{
|
||||
CodJfas = CodJfas,
|
||||
Descrizione = DescrizioneReparto
|
||||
};
|
||||
}
|
||||
return _reparto;
|
||||
}
|
||||
set
|
||||
{
|
||||
_reparto = value;
|
||||
if (value == null) return;
|
||||
|
||||
CodJfas = value.CodJfas;
|
||||
DescrizioneReparto = value.Descrizione;
|
||||
}
|
||||
}
|
||||
private JtbFasiDto? _reparto;
|
||||
}
|
||||
8
SteUp.Shared/Core/Enum/StatusEnum.cs
Normal file
8
SteUp.Shared/Core/Enum/StatusEnum.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SteUp.Shared.Core.Enum;
|
||||
|
||||
public enum StatusEnum
|
||||
{
|
||||
InCorso = 0,
|
||||
Completata = 1,
|
||||
Esporta = 2
|
||||
}
|
||||
29
SteUp.Shared/Core/Helpers/StatusEnumHelper.cs
Normal file
29
SteUp.Shared/Core/Helpers/StatusEnumHelper.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using MudBlazor;
|
||||
using SteUp.Shared.Core.Enum;
|
||||
|
||||
namespace SteUp.Shared.Core.Helpers;
|
||||
|
||||
public static class StatusEnumHelper
|
||||
{
|
||||
public static string ConvertToHumanReadable(this StatusEnum enumValue)
|
||||
{
|
||||
return enumValue switch
|
||||
{
|
||||
StatusEnum.InCorso => "IN CORSO",
|
||||
StatusEnum.Completata => "COMPLETATA",
|
||||
StatusEnum.Esporta => "ESPORTATA",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(enumValue), enumValue, null)
|
||||
};
|
||||
}
|
||||
|
||||
public static Color GetColor(this StatusEnum enumValue)
|
||||
{
|
||||
return enumValue switch
|
||||
{
|
||||
StatusEnum.InCorso => Color.Warning,
|
||||
StatusEnum.Completata or
|
||||
StatusEnum.Esporta => Color.Success,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
}
|
||||
6
SteUp.Shared/Core/Interface/LocalDb/IDbInitializer.cs
Normal file
6
SteUp.Shared/Core/Interface/LocalDb/IDbInitializer.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace SteUp.Shared.Core.Interface.LocalDb;
|
||||
|
||||
public interface IDbInitializer
|
||||
{
|
||||
Task InitializeAsync();
|
||||
}
|
||||
20
SteUp.Shared/Core/Interface/LocalDb/IIspezioniService.cs
Normal file
20
SteUp.Shared/Core/Interface/LocalDb/IIspezioniService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using SteUp.Shared.Core.Entities;
|
||||
|
||||
namespace SteUp.Shared.Core.Interface.LocalDb;
|
||||
|
||||
public interface IIspezioniService
|
||||
{
|
||||
// ISPEZIONI
|
||||
Task<Ispezione?> GetIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
||||
Task<List<Ispezione>> GetAllIspezioniWithSchedeAsync();
|
||||
Task AddIspezioneAsync(Ispezione ispezione);
|
||||
Task<Ispezione> GetOrCreateIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
||||
Task<bool> DeleteIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
||||
|
||||
// SCHEDE
|
||||
Task AddSchedaAsync(string codMdep, DateOnly data, string rilevatore, Scheda scheda);
|
||||
Task<Scheda?> GetSchedaAsync(int schedaId);
|
||||
Task<Scheda?> GetSchedaWithIspezioneAsync(int schedaId);
|
||||
Task<bool> DeleteSchedaAsync(int schedaId);
|
||||
Task<int> DeleteAllSchedeOfIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
||||
}
|
||||
Reference in New Issue
Block a user