Inheritance: Microsoft.WindowsAzure.Storage.Table.TableEntity
Ejemplo n.º 1
0
        public bool Insert(Feed feed)
        {
            var account = AzureTableExtensions.GetStorageAccount();
            var client = account.CreateCloudTableClient();
            var table = client.GetTableReference("Feed");

            try
            {
                table.Insert(feed);
            }
            catch (StorageException ex)
            {
                if (ex.InnerException is WebException && ((HttpWebResponse)((WebException)ex.InnerException).Response).StatusCode == HttpStatusCode.Conflict)
                {
                    return false;
                }
                throw;
            }
            return true;
        }
Ejemplo n.º 2
0
 public IEnumerable<Post> GetForFeed(Feed feed)
 {
     var query = new TableQuery<Post>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, Post.CreateKey(feed.PartitionKey, feed.RowKey)));
     var posts = table.ExecuteQuery(query);
     return posts;
 }
Ejemplo n.º 3
0
        public ActionResult New(FeedViewModel feedViewModel)
        {
            if (!ModelState.IsValid) return View(feedViewModel);
            var feed = new Feed(feedViewModel.UserName, feedViewModel.FeedName);

            var created = feeds.Insert(feed);
            if (created)
            {
                return RedirectToRoute("ViewFeed", new { userName = feedViewModel.UserName, feedName = feedViewModel.FeedName });
            }
            ViewBag.IsDuplicate = true;
            return View(feedViewModel);
        }
Ejemplo n.º 4
0
        public ActionResult New(FeedViewModel feedViewModel)
        {
            if (!ModelState.IsValid) return View(feedViewModel);

            var account = AzureTableExtensions.GetStorageAccount();
            var client = account.CreateCloudTableClient();
            var table = client.GetTableReference("Feed");

            var feed = new Feed(feedViewModel.UserName.ToLower(), feedViewModel.FeedName.ToLower());
            try
            {
                table.Insert(feed);
            }
            catch (StorageException ex)
            {
                if (ex.InnerException is WebException && ((HttpWebResponse) ((WebException) ex.InnerException).Response).StatusCode == HttpStatusCode.Conflict)
                {
                    ViewBag.IsDuplicate = true;
                    return View(feedViewModel);
                }
                throw;
            }

            return RedirectToRoute("ViewFeed", new { userName = feedViewModel.UserName, feedName = feedViewModel.FeedName});
        }