using AyCode.Interfaces.Enums; using AyCode.Interfaces.Messages; using AyCode.Models.Messages; using TIAM.Entities.Transfers; //using TIAM.Entities.TransferDestinations; using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; using static AyCode.Interfaces.Enums.IMessageTypes; namespace TIAMWebApp.Client.Services { public class WizardProcessor : IWizardProcessor { public ITransferDataService TransferDataService { get; set; } public IUserDataService UserDataService { get; set; } public IClientNoticeSenderService MessageSenderService { get; set; } public WizardProcessor(ITransferDataService transferDataService, IUserDataService userDataService, IClientNoticeSenderService messageSenderService) { this.TransferDataService = transferDataService; this.UserDataService = userDataService; this.MessageSenderService = messageSenderService; } public async Task ProcessWizardAsync(Type type, object data) where TModelType: class { switch (type.Name) { case "TransferDestinationWizardModel": var result = await TransferDataService.CreateTransferDestination((TransferDestination)data); return result as TModelType; case "TransferWizardModel": var transferResult = await TransferDataService.CreateTransfer((TransferWizardModel)data); return transferResult as TModelType; case "MessageWizardModel": var messageResult = await MessageSenderService.SendNoticeAsync((EmailMessage)data, 1); return messageResult as TModelType; case "ServiceProvider": return null; default: return null; } } public Task ValidateWizardStepAsync(Type type, string fieldName, object fieldValue) { //if type is TransferDestination, then validate the field name //if (type.Name == "TransferDestination") // return await TransferDataService.ValidateDestination(fieldName); //if type is ServiceProvider, then validate the field name //if type is something else, then throw an exception throw new NotImplementedException(); } } }