Example #1
0
        public async Task <PurchasedPresent> InsertOrMergePresentAsync(PurchasedPresent entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            try
            {
                // Create the InsertOrReplace table operation
                TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(entity);

                // Execute the operation.
                TableResult result = await this.presentHistoryTable.ExecuteAsync(insertOrMergeOperation);

                PurchasedPresent insertedPurchase = result.Result as PurchasedPresent;

                if (result.RequestCharge.HasValue)
                {
                    Console.WriteLine("Request Charge of InsertOrMerge Operation: " + result.RequestCharge);
                }

                return(insertedPurchase);
            }
            catch (StorageException e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
Example #2
0
        public async Task <bool> ExecuteSendEmail(PurchasedPresent presentInfo)
        {
            var client           = new SendGridClient(_apikey);
            var from             = new EmailAddress("*****@*****.**");
            var subject          = $"{presentInfo.Title} bought ({presentInfo.NewlyBought})";
            var arinconMail      = new EmailAddress("*****@*****.**");
            var paupepaMail      = new EmailAddress("*****@*****.**");
            var plainTextContent = $"{presentInfo.Title}";
            var htmlContent      = $"<strong>Someone just bought something!</strong><div>{presentInfo.Title}</div>";
            var msg = MailHelper.CreateSingleEmailToMultipleRecipients(from, new List <EmailAddress> {
                arinconMail, paupepaMail
            }, subject, plainTextContent, htmlContent);
            var response = await client.SendEmailAsync(msg);

            return(response.IsSuccessStatusCode);
        }
Example #3
0
 public async Task <bool> SendEmail(PurchasedPresent presentInfo)
 {
     return(await ExecuteSendEmail(presentInfo));
 }