Exemple #1
0
 public IHttpActionResult GetSubscription()
 {
     try
     {
         ConfigureNLog();
         NLog.LogManager.GetLogger("aws").Info("GetSubscription Entered");
         var endpoint = ConfigurationManager.AppSettings["SnsEndpoint"];
         var topicarn = ConfigurationManager.AppSettings["SnsEventsTopicArn"];
         var client   = new Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient();
         var request  = new AM.SubscribeRequest
         {
             Protocol = "https",
             Endpoint = endpoint,
             TopicArn = topicarn
         };
         var response = client.Subscribe(request);
         NLog.LogManager.GetLogger("aws").Info("GetSubscription returned response SubscriptionArn=" + response.SubscriptionArn);
         return(Ok(response.SubscriptionArn)); //TODO - stuff this in database, on PostConfirmation verify response topic is pending
     }
     catch (Exception ex)
     {
         string msg = ex.ToString();
         try
         {
             NLog.LogManager.GetLogger("aws").Info("GetSubscription got error " + ex.ToString());
         } catch (Exception ex2)
         {
         }
         return(BadRequest("AN ERROR HAPEPNED: " + msg));
     }
 }
Exemple #2
0
        public async Task <IHttpActionResult> Register(Models.RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new ApplicationUser()
            {
                UserName = model.Email, Email = model.Email, Firstname = model.Firstname, Lastname = model.Lastname
            };

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            RegionEndpoint regionep  = Amazon.RegionEndpoint.GetBySystemName(System.Web.Configuration.WebConfigurationManager.AppSettings["region"]);
            string         awskey    = System.Web.Configuration.WebConfigurationManager.AppSettings["awskey"];
            string         awssecret = System.Web.Configuration.WebConfigurationManager.AppSettings["awssecret"];
            string         arn       = System.Web.Configuration.WebConfigurationManager.AppSettings["awssnstopic"];

            Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient simp = new Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient(awskey, awssecret, new Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceConfig
            {
                RegionEndpoint = regionep
            });
            simp.Subscribe(arn, "email", model.Email);
            simp.PublishAsync(arn, "Please welcome to Tune World " + model.Firstname + " " + model.Lastname, "Tune World Registration");

            return(Ok());
        }