예제 #1
0
        public static void EditData(Consultant item)
        {
            // Create a retrieve operation that takes a customer entity.
            TableOperation retrieveOperation = TableOperation.Retrieve<Consultant>(partitionKey, item.RowKey);

            // Execute the operation.
            TableResult retrievedResult = table.Execute(retrieveOperation);

            // Assign the result to a CustomerEntity object.
            Consultant replaceThisItem = (Consultant)retrievedResult.Result;

            if (replaceThisItem != null)
            {
                // Change the name.
                replaceThisItem.Name = item.Name;
                replaceThisItem.EmploymentDate = item.EmploymentDate;

                // Create the InsertOrReplace TableOperation.
                TableOperation updateOperation = TableOperation.Replace(replaceThisItem);

                // Execute the operation.
                table.Execute(updateOperation);

                Console.WriteLine("Entity updated.");
            }

            else { Console.WriteLine("Entity could not be retrieved."); }
        }
예제 #2
0
        public static void AddData(Consultant item)
        {
            // Create the TableOperation object that inserts the customer entity.
            TableOperation insertOperation = TableOperation.Insert(item);

            // Execute the insert operation.
            table.Execute(insertOperation);
        }
        public HttpResponseMessage Add(Consultant item)
        {
            BonsuPortal.AzureManager.AddData(item);

            //BonsuPortal.AzureManager.EditData(item);

            var response = Request.CreateResponse<Consultant>(HttpStatusCode.Created, item);

            //string uri = Url.Link("DefaultApi", new { name = item.Name });
            //response.Headers.Location = new Uri(uri);
            return response;
        }
        public HttpResponseMessage Remove(Consultant item)
        {
            HttpResponseMessage response;

            var target = consultants.FirstOrDefault((c) => c.RowKey == item.RowKey);
            if (target == null)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound);
                return response;
            }

            BonsuPortal.AzureManager.DeleteData(item);

            response = Request.CreateResponse(HttpStatusCode.OK);
            return response;
        }
예제 #5
0
        public static void DeleteData(Consultant item)
        {
            // Create a retrieve operation that takes a customer entity.
            TableOperation retrieveOperation = TableOperation.Retrieve<Consultant>(partitionKey, item.RowKey);

            // Execute the operation.
            TableResult retrievedResult = table.Execute(retrieveOperation);

            // Assign the result to a CustomerEntity object.
            Consultant deleteThisItem = (Consultant)retrievedResult.Result;

            if (deleteThisItem != null)
            {
                // Delete
                TableOperation deleteOperation = TableOperation.Delete(deleteThisItem);

                // Execute the operation.
                table.Execute(deleteOperation);

                Console.WriteLine("Entity deleted.");
            }

            else { Console.WriteLine("Entity could not be deleted."); }
        }