public IServiceAction CreateActionFromModel(ActionModel actionModel) { switch (actionModel.Type) { case ActionType.SampleOperation: { if (_clientsManagement.IsRegistered(actionModel.ClientId)) { return(new SampleOperationAction(_clientsManagement, _notificationFactory)); } return(new InvalidAction()); } case ActionType.RegisterClient: { return(new RegisterClientAction(actionModel.ClientId, _clientsManagement, _notificationFactory)); } case ActionType.UnregisterClient: { if (_clientsManagement.IsRegistered(actionModel.ClientId)) { return(new UnregisterClientAction(actionModel.ClientId, _clientsManagement)); } return(new InvalidAction()); } case ActionType.UpdateChannel: { if (_clientsManagement.IsRegistered(actionModel.ClientId)) { return(new UpdateChannelAction(actionModel.ClientId, _clientsManagement)); } return(new InvalidAction()); } case ActionType.Invalid: { return(new InvalidAction()); } default: return(new InvalidAction()); } }
public void Execute() { if (_clientId == Guid.Empty) { return; } if (_clientsManagement.IsRegistered(_clientId)) { return; } var newClient = new ClientModel() { Id = _clientId, CallbackChannel = OperationContext.Current.GetCallbackChannel <ICallbackContract>() }; _clientsManagement.Insert(newClient); _notificationFactory.GeneralStatus("Registered successfully.").NotifyById(_clientId); }