using Microsoft.AspNetCore.Components; using WebDoorCreator.Data; using WebDoorCreator.Data.DbModels; using WebDoorCreator.Data.Services; using static Org.BouncyCastle.Math.EC.ECCurve; namespace WebDoorCreator.UI.Data { public class WDCRefreshService { #region Public Events public event EventHandler EA_ConfDoorOp = delegate { }; public event EventHandler EA_OrderChanged = delegate { }; public event Action EA_UpdDoorOp = null!; #endregion Public Events #region Public Properties public bool isDoorOpUpd { get => _isDoorOpUpd; set { _isDoorOpUpd = value; reportDoorOpUpd(); } } #endregion Public Properties #region Public Methods public void ReportDoorOpConf(int doorId, int doorOpId, string objId) { DOPEventArgs currOpr = new DOPEventArgs() { DoorId = doorId, DoorOpId = doorOpId, ObjectId = objId }; // se qualcuno ascolta sollevo evento nuovo valore... if (EA_ConfDoorOp != null) { EA_ConfDoorOp(this, currOpr); } } public void ReportOrderChanged(int orderId) { OrdEventArgs currOpr = new OrdEventArgs() { OrderId = orderId }; // se qualcuno ascolta sollevo evento nuovo valore... if (EA_OrderChanged != null) { EA_OrderChanged(this, currOpr); } } #endregion Public Methods #region Public Classes public class DOPEventArgs : EventArgs { #region Public Properties public int DoorId { get; set; } = 0; public int DoorOpId { get; set; } = 0; public string ObjectId { get; set; } = ""; #endregion Public Properties } public class OrdEventArgs : EventArgs { #region Public Properties public int OrderId { get; set; } = 0; #endregion Public Properties } #endregion Public Classes #region Protected Methods protected void reportDoorOpUpd() { if (EA_UpdDoorOp != null) { EA_UpdDoorOp?.Invoke(); } } #endregion Protected Methods #region Private Properties private bool _isDoorOpConf { get; set; } = false; private bool _isDoorOpUpd { get; set; } = false; #endregion Private Properties } }