private static async Task BasicDataOperationsAsync(CloudTable table)
        {
            // Create an instance of a customer entity. See the Model\CustomerEntity.cs for a description of the entity.
            SingleEntity entity = new SingleEntity("CricketAnswerV2", "en-us")
            {
                RawQuery = "Cricket World Cup"
            };

            // Demonstrate how to insert the entity
            Console.WriteLine("Insert an Entity.");
            entity = await SamplesUtils.InsertOrMergeEntityAsync(table, entity);

            // Demonstrate how to Update the entity by changing the phone number
            Console.WriteLine("Update an existing Entity using the InsertOrMerge Upsert Operation.");
            entity.RawQuery = "ICC WORLDCUP";
            await SamplesUtils.InsertOrMergeEntityAsync(table, entity);

            Console.WriteLine();

            // Demonstrate how to Read the updated entity using a point query
            Console.WriteLine("Reading the updated Entity.");
            entity = await SamplesUtils.RetrieveEntityUsingPointQueryAsync(table, "CricketAnswerV2", "en-us");

            //    Console.WriteLine(entity.RawQuery);

            // Demonstrate how to Delete an entity
            //Console.WriteLine("Delete the entity. ");
            //await SamplesUtils.DeleteEntityAsync(table, customer);
            //Console.WriteLine();
        }
Beispiel #2
0
        public static async Task DeleteEntityAsync(CloudTable table, SingleEntity deleteEntity)
        {
            try
            {
                if (deleteEntity == null)
                {
                    throw new ArgumentNullException("deleteEntity");
                }

                TableOperation deleteOperation = TableOperation.Delete(deleteEntity);
                TableResult    result          = await table.ExecuteAsync(deleteOperation);

                // Get the request units consumed by the current operation. RequestCharge of a TableResult is only applied to Azure CosmoS DB
                if (result.RequestCharge.HasValue)
                {
                    Console.WriteLine("Request Charge of Delete Operation: " + result.RequestCharge);
                }
            }
            catch (StorageException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                throw;
            }
        }
Beispiel #3
0
        public static async Task <SingleEntity> RetrieveEntityUsingPointQueryAsync(CloudTable table, string partitionKey, string rowKey)
        {
            try
            {
                TableOperation retrieveOperation = TableOperation.Retrieve <SingleEntity>(partitionKey, rowKey);
                TableResult    result            = await table.ExecuteAsync(retrieveOperation);

                SingleEntity entity = result.Result as SingleEntity;
                if (entity != null)
                {
                    Console.WriteLine("\t{0}\t{1}\t{2}\t{3}", entity.PartitionKey, entity.RowKey, entity.RawQuery);
                }

                // Get the request units consumed by the current operation. RequestCharge of a TableResult is only applied to Azure CosmoS DB
                if (result.RequestCharge.HasValue)
                {
                    Console.WriteLine("Request Charge of Retrieve Operation: " + result.RequestCharge);
                }

                return(entity);
            }
            catch (StorageException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                throw;
            }
        }
Beispiel #4
0
        public static async Task <SingleEntity> InsertOrMergeEntityAsync(CloudTable table, SingleEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            try
            {
                // Create the InsertOrReplace table operation
                TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(entity);

                // Execute the operation.
                TableResult result = await table.ExecuteAsync(insertOrMergeOperation);

                SingleEntity insertedCustomer = result.Result as SingleEntity;

                // Get the request units consumed by the current operation. RequestCharge of a TableResult is only applied to Azure CosmoS DB
                if (result.RequestCharge.HasValue)
                {
                    Console.WriteLine("Request Charge of InsertOrMerge Operation: " + result.RequestCharge);
                }

                return(insertedCustomer);
            }
            catch (StorageException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                throw;
            }
        }
    public ActionResult GetModel()
    {
        MainModel             mainModel    = new MainModel();
        List <SimpleDropdown> dropdownlist = new List <SimpleDropdown>();
        List <SingleEntity>   selist       = new List <SingleEntity>();

        for (int j = 1; j < 10; j++)
        {
            dropdownlist.Add(new SimpleDropdown {
                Text = "Text" + j, Value = j.ToString()
            });
        }
        SingleEntity se;

        for (int i = 0; i < 10; i++)
        {
            se                        = new SingleEntity();
            se.Id                     = i;
            se.Name                   = "Name" + i;
            se.SelectedEmp            = i;
            se.dddl                   = dropdownlist;
            mainModel.main_model_list = selist;
            mainModel.main_model_list.Add(se);
        }
        return(View(mainModel));
    }
Beispiel #6
0
        public ActionResult Cevapla()
        {
            MainModel             main         = new MainModel();
            List <SimpleDropdown> dropdownlist = new List <SimpleDropdown>();
            List <SingleEntity>   selist       = new List <SingleEntity>();
            var secenekler = db.AnketSecenek.ToList();
            var sorular    = db.AnketSoru.ToList();

            foreach (var item in secenekler)
            {
                dropdownlist.Add(new SimpleDropdown {
                    Text = item.anketSecenekIcerik, Value = item.anketSecenekID.ToString(), SoruID = item.anketSoruID
                });
            }
            SingleEntity se;

            foreach (var item in sorular)
            {
                se      = new SingleEntity();
                se.ddl  = new List <SimpleDropdown>();
                se.soru = new AnketSoru();
                se.soru = item;
                for (int i = 0; i < dropdownlist.Count; i++)
                {
                    if (dropdownlist[i].SoruID == item.anketSoruID)
                    {
                        se.ddl.Add(dropdownlist[i]);
                    }
                    se.Selected = Convert.ToInt32(dropdownlist[i].Value);
                }
                main.main_model_list = selist;
                main.main_model_list.Add(se);
            }



            return(View(main));
        }