public static void Register() { GetState = a => a.State; new ConstructFrom <Entity>(AlertOperation.CreateAlertFromEntity) { ToStates = { AlertState.New }, Construct = (a, _) => new AlertEntity { AlertDate = TimeZoneManager.Now, CreatedBy = UserHolder.Current.ToLite(), Recipient = AlertLogic.DefaultRecipient()?.ToLite(), Text = "", Title = null, Target = a.ToLite(), AlertType = null } }.Register(); new Construct(AlertOperation.Create) { ToStates = { AlertState.New },
public static void Register() { GetState = a => a.State; new ConstructFrom <Entity>(AlertOperation.CreateAlertFromEntity) { ToStates = { AlertState.New }, Construct = (a, _) => new AlertEntity { AlertDate = TimeZoneManager.Now, CreatedBy = UserHolder.Current.ToLite(), Recipient = AlertLogic.DefaultRecipient()?.ToLite(), Text = null, Title = null, Target = a.ToLite(), AlertType = null } }.Register(); new Execute(AlertOperation.Save) { FromStates = { AlertState.Saved, AlertState.New }, ToStates = { AlertState.Saved }, AllowsNew = true, Lite = false, Execute = (a, _) => { a.State = AlertState.Saved; } }.Register(); new Execute(AlertOperation.Attend) { FromStates = { AlertState.Saved }, ToStates = { AlertState.Attended }, Execute = (a, _) => { a.State = AlertState.Attended; a.AttendedDate = TimeZoneManager.Now; a.AttendedBy = UserEntity.Current.ToLite(); } }.Register(); new Execute(AlertOperation.Unattend) { FromStates = { AlertState.Attended }, ToStates = { AlertState.Saved }, Execute = (a, _) => { a.State = AlertState.Saved; a.AttendedDate = null; a.AttendedBy = null; } }.Register(); new Execute(AlertOperation.Delay) { FromStates = { AlertState.Saved }, ToStates = { AlertState.Saved }, Execute = (a, args) => { a.AlertDate = args.GetArg <DateTime>(); } }.Register(); }