Example #1
0
 public ActionResult Index()
 {
     try
     {
         var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
         cloudTableClient.CreateTableIfNotExist("Customers");
         var context = new CustomerDataContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials);
         var list = context.Customers.ToList();
         // 如果表中有实体信息则显示该表到UI层
         if (list.Count() > 0)
         {
             MVCSessionCachedDataProvider<Customer> provider = new MVCSessionCachedDataProvider<Customer>(this, "provider1");
             TableStoragePagingUtility<Customer> pagingUtility = new TableStoragePagingUtility<Customer>(provider, cloudStorageAccount,
                 context, 10, "Customers");
             return View("Index", new CustomersSet() { Customers = pagingUtility.GetCurrentOrFirstPage().ToList(), ReadyToShowUI = true });
         }
         else
         {
             //如果表中没有实体显示指引用户向表中添加数据的链接.
             ViewResult vr = View("Index", new CustomersSet() { ReadyToShowUI = false });
             return vr;
         }
     }
     catch (Exception ex)
     {
         return View("Error", new HandleErrorInfo(ex, "HomeController", "Index"));
     }
 }
Example #2
0
        public ActionResult AddDataToTest()
        {
            var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
            var context          = new CustomerDataContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials);

            try
            {
                // 向表中添加65个实体
                for (int i = 0; i < 65; i++)
                {
                    context.AddObject("Customers", new Customer()
                    {
                        Age = r.Next(16, 70), Name = "Customer" + i.ToString()
                    });
                }
                context.SaveChanges();
                MVCSessionCachedDataProvider <Customer> provider      = new MVCSessionCachedDataProvider <Customer>(this, "provider1");
                TableStoragePagingUtility <Customer>    pagingUtility = new TableStoragePagingUtility <Customer>(provider, cloudStorageAccount,
                                                                                                                 context, 10, "Customers");
                return(View("Index", new CustomersSet()
                {
                    Customers = pagingUtility.GetNextPage().ToList(), ReadyToShowUI = true
                }));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "HomeController", "AddDataToTest")));
            }
        }
Example #3
0
 public ActionResult Index()
 {
     try
     {
         var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
         cloudTableClient.CreateTableIfNotExist("Customers");
         var context = new CustomerDataContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials);
         var list    = context.Customers.ToList();
         // 如果表中有实体信息则显示该表到UI层
         if (list.Count() > 0)
         {
             MVCSessionCachedDataProvider <Customer> provider      = new MVCSessionCachedDataProvider <Customer>(this, "provider1");
             TableStoragePagingUtility <Customer>    pagingUtility = new TableStoragePagingUtility <Customer>(provider, cloudStorageAccount,
                                                                                                              context, 10, "Customers");
             return(View("Index", new CustomersSet()
             {
                 Customers = pagingUtility.GetCurrentOrFirstPage().ToList(), ReadyToShowUI = true
             }));
         }
         else
         {
             //如果表中没有实体显示指引用户向表中添加数据的链接.
             ViewResult vr = View("Index", new CustomersSet()
             {
                 ReadyToShowUI = false
             });
             return(vr);
         }
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "HomeController", "Index")));
     }
 }
Example #4
0
 public ActionResult Index()
 {
     try
     {
         var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
         cloudTableClient.CreateTableIfNotExist("Customers");
         var context = new CustomerDataContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials);
         var list    = context.Customers.ToList();
         // If there are entities in the table show UI that renders the table
         if (list.Count() > 0)
         {
             MVCSessionCachedDataProvider <Customer> provider      = new MVCSessionCachedDataProvider <Customer>(this, "provider1");
             TableStoragePagingUtility <Customer>    pagingUtility = new TableStoragePagingUtility <Customer>(provider, cloudStorageAccount,
                                                                                                              context, 10, "Customers");
             return(View("Index", new CustomersSet()
             {
                 Customers = pagingUtility.GetCurrentOrFirstPage().ToList(), ReadyToShowUI = true
             }));
         }
         else
         {
             //If there is no entity in the table show link to guide user to add data to table.
             ViewResult vr = View("Index", new CustomersSet()
             {
                 ReadyToShowUI = false
             });
             return(vr);
         }
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "HomeController", "Index")));
     }
 }
Example #5
0
        public ActionResult Previous()
        {
            var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
            var context          = new CustomerDataContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials);
            MVCSessionCachedDataProvider <Customer> provider      = new MVCSessionCachedDataProvider <Customer>(this, "provider1");
            TableStoragePagingUtility <Customer>    pagingUtility = new TableStoragePagingUtility <Customer>(provider, cloudStorageAccount,
                                                                                                             context, 10, "Customers");

            return(View("Index", new CustomersSet()
            {
                Customers = pagingUtility.GetPreviousPage().ToList(), ReadyToShowUI = true
            }));
        }
Example #6
0
 public ActionResult AddDataToTest()
 {
     var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
     var context = new CustomerDataContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials);
     try
     {
         // 向表中添加65个实体
         for (int i = 0; i < 65; i++)
         {
             context.AddObject("Customers", new Customer() { Age = r.Next(16, 70), Name = "Customer" + i.ToString() });
         }
         context.SaveChanges();
         MVCSessionCachedDataProvider<Customer> provider = new MVCSessionCachedDataProvider<Customer>(this, "provider1");
         TableStoragePagingUtility<Customer> pagingUtility = new TableStoragePagingUtility<Customer>(provider, cloudStorageAccount,
             context, 10, "Customers");
         return View("Index", new CustomersSet() { Customers = pagingUtility.GetNextPage().ToList(), ReadyToShowUI = true });
     }
     catch (Exception ex)
     {
         return View("Error",new HandleErrorInfo(ex,"HomeController","AddDataToTest"));
     }
 }
Example #7
0
 public ActionResult Next()
 {
     var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
     var context = new CustomerDataContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials);
     MVCSessionCachedDataProvider<Customer> provider = new MVCSessionCachedDataProvider<Customer>(this, "provider1");
     TableStoragePagingUtility<Customer> pagingUtility = new TableStoragePagingUtility<Customer>(provider, cloudStorageAccount,
         context, 10, "Customers");
     return View("Index", new CustomersSet() { Customers = pagingUtility.GetNextPage().ToList(), ReadyToShowUI=true });
 }