public String Transaction(Models.TransferData data)
        {
            String message = "";
            List <CSharp2nem.Model.Transfer.Mosaics.Mosaic> MosaicList = new List <CSharp2nem.Model.Transfer.Mosaics.Mosaic>();
            var connection = new Connection();

            connection.SetTestnet();

            var mosaicClient   = new NamespaceMosaicClient(connection);
            var mosaicResult   = mosaicClient.BeginGetMosaicsOwned(data.Sender);
            var mosaicResponse = mosaicClient.EndGetMosaicsOwned(mosaicResult);

            foreach (var mosaic in mosaicResponse.Data)
            {
                if (mosaic.MosaicId.Name == "tfc")
                {
                    MosaicList.Add(new CSharp2nem.Model.Transfer.Mosaics.Mosaic(mosaic.MosaicId.NamespaceId, mosaic.MosaicId.Name, (data.Amount * 10000)));
                }
            }

            var accountFactory = new PrivateKeyAccountClientFactory(connection);
            var accClient      = accountFactory.FromPrivateKey(data.SenderPrivateKey);

            var transData = new TransferTransactionData()
            {
                Amount           = 1000000, // amount should always be 1000000 micro xem when attaching mosaics as it acts as a multiplier.
                RecipientAddress = data.Receiver,
                ListOfMosaics    = MosaicList
            };

            try
            {
                accClient.BeginSendTransaction(body =>
                {
                    try
                    {
                        if (body.Ex != null)
                        {
                            throw body.Ex;
                        }
                        message = body.Content.Message;
                        Debug.WriteLine(message);
                    }
                    catch (Exception e)
                    {
                        message = e.Message;
                    }
                }, transData);
            }
            catch (Exception e)
            {
                message = e.Message;
            }
            Thread.Sleep(5000); //to make sure the message variable gets the content message before terminating
            return(message);
        }
        public bool Send(string address, string message, Mosaic mosaic, long amount)
        {
            try
            {
                var accountFactory = new PrivateKeyAccountClientFactory(connection);
                var accountClient  = accountFactory.FromPrivateKey(PrivateKey);

                TransferTransactionData transData;
                if (mosaic.MosaicName == "xem")
                {
                    transData = new TransferTransactionData()
                    {
                        Amount           = amount,
                        Message          = message,
                        RecipientAddress = address,
                    };
                }
                else
                {
                    mosaic.Quantity = amount;
                    transData       = new TransferTransactionData()
                    {
                        Amount           = 1000000,
                        Message          = message,
                        RecipientAddress = address,
                        ListOfMosaics    = new List <Mosaic>()
                        {
                            mosaic
                        },
                    };
                }

                var accountResult = accountClient.BeginSendTransaction(transData);

                while (!accountResult.IsCompleted)
                {
                    ;
                }

                return(accountClient.EndTransaction(accountResult).Message == "SUCCESS");
            }
            catch (Exception ex)
            {
                return(false);
            }
        }