public ActionResult Create(MonitoredSite monitoredsite)
        {
            if (ModelState.IsValid)
            {
                db.MonitoredSites.Add(monitoredsite);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(monitoredsite);
        }
        private async Task<SiteStatusResult> CheckSite(MonitoredSite site)
        {
            var status = new SiteStatusResult { SiteId = site.Id, Url = site.Url };

            var client = new WebClient();

            var response = await client.DownloadStringTaskAsync(site.Url).ContinueWith(async (t) =>
            {
                status.Status = t.IsFaulted
                    ? SiteStatus.Down.ToString()
                    : SiteStatus.Up.ToString();
            });

            return status;
        }
        private async Task<SiteStatusResult> CheckSite(MonitoredSite site)
        {
            var status = new SiteStatusResult { SiteId = site.Id, Url = site.Url };

            var client = new WebClient();

            var response = await client.DownloadStringTaskAsync(site.Url).ContinueWith(async (t) =>
            {
                status.Status = t.IsFaulted
                    ? SiteStatus.Down.ToString()
                    : SiteStatus.Up.ToString();

                // put the URL onto the queue if the site is online
                //if (!t.IsFaulted)
                //{
                //    var account = CloudStorageAccount.DevelopmentStorageAccount;
                //    var queue = account.CreateCloudQueueClient().GetQueueReference("incoming");
                //    queue.CreateIfNotExists();
                //    queue.AddMessage(new CloudQueueMessage(status.Url));
                //}

                // send the results to the service bus
                var connectionString =
                    ConfigurationManager
                        .AppSettings["serviceBusConnectionString"];

                ServiceBusHelper.ServiceBus
                    .Setup(connectionString, "sitemonitr")
                    .Publish<SitePingResult>(new SitePingResult
                    {
                        Id = site.Id,
                        Url = site.Url,
                        Status = status.Status,
                        TimeStamp = DateTime.Now
                    });
            });

            return status;
        }
        private async Task<SiteStatusResult> CheckSite(MonitoredSite site)
        {
            var status = new SiteStatusResult { SiteId = site.Id, Url = site.Url };

            var client = new WebClient();

            var response = await client.DownloadStringTaskAsync(site.Url).ContinueWith(async (t) =>
            {
                status.Status = t.IsFaulted
                    ? SiteStatus.Down.ToString()
                    : SiteStatus.Up.ToString();

                // put the URL onto the queue if the site is online
                if (!t.IsFaulted)
                {
                    var account = CloudStorageAccount.DevelopmentStorageAccount;
                    var queue = account.CreateCloudQueueClient().GetQueueReference("incoming");
                    queue.CreateIfNotExists();
                    queue.AddMessage(new CloudQueueMessage(status.Url));
                }
            });

            return status;
        }
 public ActionResult Edit(MonitoredSite monitoredsite)
 {
     if (ModelState.IsValid)
     {
         db.Entry(monitoredsite).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(monitoredsite);
 }