public ActionResult Create(MailingList mailingList)
        {
            if (ModelState.IsValid)
            {
                var insertOperation = TableOperation.Insert(mailingList);
                mailingListTable.Execute(insertOperation);
                return RedirectToAction("Index");
            }

            return View(mailingList);
        }
 private static void SendSubscribeEmail(string subscriberGUID, Subscriber subscriber, MailingList mailingList)
 {
     var email = SendGrid.GetInstance();
     email.From = new MailAddress(mailingList.FromEmailAddress);
     email.AddTo(subscriber.EmailAddress);
     string subscribeURL = RoleEnvironment.GetConfigurationSettingValue("AzureMailServiceURL") +
         "/subscribe?id=" + subscriberGUID + "&listName=" + subscriber.ListName;
     email.Html = String.Format("<p>Click the link below to subscribe to {0}. " +
         "If you don't confirm your subscription, you won't be subscribed to the list.</p>" +
         "<a href=\"{1}\">Confirm Subscription</a>", mailingList.Description, subscribeURL);
     email.Text = String.Format("Copy and paste the following URL into your browser in order to subscribe to {0}. " +
         "If you don't confirm your subscription, you won't be subscribed to the list.\n" +
         "{1}", mailingList.Description, subscribeURL);
     email.Subject = "Subscribe to " + mailingList.Description;
     var credentials = new NetworkCredential(RoleEnvironment.GetConfigurationSettingValue("SendGridUserName"), RoleEnvironment.GetConfigurationSettingValue("SendGridPassword"));
     var transportREST = Web.GetInstance(credentials);
     transportREST.Deliver(email);
 }
 public async Task<ActionResult> Edit(string partitionKey, string rowKey, MailingList editedMailingList)
 {
     if (ModelState.IsValid)
     {
         var mailingList = new MailingList();
         UpdateModel(mailingList);
         try
         {
             var replaceOperation = TableOperation.Replace(mailingList);
             await mailingListTable.ExecuteAsync(replaceOperation);
             return RedirectToAction("Index");
         }
         catch (StorageException ex)
         {
             if (ex.RequestInformation.HttpStatusCode == 412)
             {
                 // Concurrency error
                 var retrieveOperation = TableOperation.Retrieve<MailingList>(partitionKey, rowKey);
                 var retrievedResult = mailingListTable.Execute(retrieveOperation);
                 var currentMailingList = retrievedResult.Result as MailingList;
                 if (currentMailingList == null)
                 {
                     ModelState.AddModelError(string.Empty, "The record you attempted to edit "
                         + "was deleted by another user after you got the original value. The "
                         + "edit operation was canceled. Click the Back to List hyperlink.");
                 }
                 if (currentMailingList.FromEmailAddress != editedMailingList.FromEmailAddress)
                 {
                     ModelState.AddModelError("FromEmailAddress", "Current value: " + currentMailingList.FromEmailAddress);
                 }
                 if (currentMailingList.Description != editedMailingList.Description)
                 {
                     ModelState.AddModelError("Description", "Current value: " + currentMailingList.Description);
                 }
                 ModelState.AddModelError(string.Empty, "The record you attempted to edit "
                     + "was modified by another user after you got the original value. The "
                     + "edit operation was canceled and the current values in the database "
                     + "have been displayed. If you still want to edit this record, click "
                     + "the Save button again. Otherwise click the Back to List hyperlink.");
                 ModelState.SetModelValue("ETag", new ValueProviderResult(currentMailingList.ETag, currentMailingList.ETag, null));
             }
             else
             {
                 throw;
             }
         }
     }
     return View(editedMailingList);
 }
 internal void Update(MailingList mailingList)
 {
     var insertOperation = TableOperation.Replace(mailingList);
     mailingListTable.Execute(insertOperation);
 }
 internal void DeleteTable(MailingList mailingList)
 {
     var insertOperation = TableOperation.Delete(mailingList);
     mailingListTable.Execute(insertOperation);
 }
 internal void SaveTable(MailingList mailingList)
 {
     var insertOperation = TableOperation.Insert(mailingList);
     mailingListTable.Execute(insertOperation);
 }
        public ActionResult Create(MailingList mailingList)
        {
            if (ModelState.IsValid)
            {
                using (MD5CryptoServiceExample md5CryptoService = new MD5CryptoServiceExample())
                {
                    MailingList encrptionMail = new MailingList()
                    {
                        Description = md5CryptoService.Encrypt(mailingList.Description, false),
                        FromEmailAddress = md5CryptoService.Encrypt(mailingList.FromEmailAddress, false),
                        ListName = mailingList.ListName,
                    };

                    DataAccess dataLayer = new DataAccess();
                    dataLayer.SaveTable(encrptionMail);
                }                

                return RedirectToAction("Index");

            }

            return View(mailingList);
        }
 internal void DeleteTable(MailingList mailingList)
 {
     tableDataSave = new TableHelper(storageAccountConnectionString);
     tableDataSave.DeleteTable(mailingList);
 }