From 4820875d7c24d7de668fb1f3b52b6a15be980930 Mon Sep 17 00:00:00 2001 From: Jovan Popovic Date: Tue, 28 Mar 2017 15:02:36 +0200 Subject: [PATCH] Removed some dead code in IVS example --- .../Controllers/ODataController.cs | 173 +----------------- 1 file changed, 1 insertion(+), 172 deletions(-) diff --git a/samples/demos/ivs-people-register/Controllers/ODataController.cs b/samples/demos/ivs-people-register/Controllers/ODataController.cs index 5ec90023..602be960 100644 --- a/samples/demos/ivs-people-register/Controllers/ODataController.cs +++ b/samples/demos/ivs-people-register/Controllers/ODataController.cs @@ -19,7 +19,6 @@ namespace Register.Controllers .AddColumn("address", "nvarchar") .AddColumn("town", "nvarchar"); - public string ODataMetadataUrl { get @@ -37,13 +36,7 @@ namespace Register.Controllers [HttpGet] public string Get() { - try - { - return ODataHandler.GetRootMetadataJsonV4(ODataMetadataUrl, new TableSpec[] { tableSpec }); - } catch (Exception ex) - { - return ex.Message; - } + return ODataHandler.GetRootMetadataJsonV4(ODataMetadataUrl, new TableSpec[] { tableSpec }); } @@ -51,12 +44,7 @@ namespace Register.Controllers [HttpGet("$metadata")] public string Metadata() { - try { return ODataHandler.GetMetadataXmlV4(new TableSpec[] { tableSpec }, "Demo.Models"); - } catch (Exception ex) - { - return ex.Message; - } } // GET api/odata/People @@ -75,164 +63,5 @@ namespace Register.Controllers { return this.People(); } - - /// - /// Endpoint that exposes People information using OData protocol. - /// - /// OData response. - // GET api/OData/People - [HttpGet("Product")] - public async Task OData() - { - Response.ContentType = "application/json;odata.metadata=minimal;odata=minimalmetadata"; - //var body = Encoding.UTF8.GetBytes(@"{""@odata.context"":""http://localhost:59934/api/odata/$metadata#Product"",""value"":[{""id"":1,""name"":""Test""}]}"); - - //await Response.Body.WriteAsync(body, 0, body.Length); - - await this - .ODataHandler(tableSpec, pipe) - .Get(); - } - - - - /// - /// Method that process server-side processing JQuery DataTables HTTP request - /// and returns data that should be shown. - /// - /// - // GET api/People - //[HttpGet] - public string GetOld() - { - //Response.ContentType = "application/json;odata=minimalmetadata;streaming=true;charset=utf-8"; - - //return "{\"odata.metadata\":\"http://services.odata.org/V3/Northwind/Northwind.svc/$metadata\",\"value\":[{\"name\":\"People\",\"url\":\"People\"}]}"; - //Response.ContentType = "application/json;odata=nometadata;streaming=true;charset=utf-8"; - //return "{\"odata.metadata\":\"http://services.odata.org/V3/Northwind/Northwind.svc/$metadata\",\"value\":[{\"name\":\"People\",\"url\":\"People\"}]}"; - - // radi: - //Response.ContentType = "application/xml;charset=utf-8"; - //return @"DefaultCategoriesCustomerDemographicsCustomersEmployeesOrder_DetailsOrdersProductsRegionsShippersSuppliersTerritoriesAlphabetical_list_of_productsCategory_Sales_for_1997Current_Product_ListsCustomer_and_Suppliers_by_CitiesInvoicesOrder_Details_ExtendedsOrder_SubtotalsOrders_QriesProduct_Sales_for_1997Products_Above_Average_PricesProducts_by_CategoriesSales_by_CategoriesSales_Totals_by_AmountsSummary_of_Sales_by_QuartersSummary_of_Sales_by_Years"; - - Response.ContentType = "application/xml;charset=utf-8"; - return @"DefaultProduct"; - } - - //[HttpGet("$metadata")] - //public string Metadata1() - //{ - // Response.ContentType = "application/xml;charset=utf-8"; - - // return ODataMetaData(this.tableSpec, "Models", "Product"); - - //} - - - [HttpGet("$metadata2")] - public string Metadata2() - { - //Response.ContentType = "application/json;odata=minimalmetadata;streaming=true;charset=utf-8"; - - //return "{\"odata.metadata\":\"http://services.odata.org/V3/Northwind/Northwind.svc/$metadata\",\"value\":[{\"name\":\"People\",\"url\":\"People\"}]}"; - //Response.ContentType = "application/json;odata=minimalmetadata;streaming=true;charset=utf-8"; - //return "{\"odata.metadata\":\"http://services.odata.org/V3/Northwind/Northwind.svc/$metadata\",\"value\":[{\"name\":\"Categories\",\"url\":\"Categories\"}]}"; - Response.ContentType = "application/xml;charset=utf-8"; - - //var wc = new System.Net.WebRequest(); - - - return @" - - - - - - - - - - - - - - - - - - "; - } - - - private string SqlTypeToDemType(string sqlType) - { - switch (sqlType) - { - case "bigint": return "Edm.Int64"; - case "binary": return "Edm.Byte[]"; - case "bit": return "Edm.Boolean"; - case "char": return "Edm.String"; - case "date": return "Edm.DateTime"; - case "datetime": return "Edm.DateTime"; - case "datetime2": return "Edm.DateTime"; - case "datetimeoffset": return "Edm.DateTimeOffset"; - case "decimal": return "Edm.Decimal"; - case "float": return "Edm.Double"; - case "image": return "Edm.Byte[]"; - case "int": return "Edm.Int32"; - case "money": return "Edm.Decimal"; - case "nchar": return "Edm.String"; - case "ntext": return "Edm.String"; - case "numeric": return "Edm.Decimal"; - case "nvarchar": return "Edm.String"; - case "real": return "Edm.Single"; - case "rowversion": return "Edm.Byte[]"; - case "smalldatetime": return "Edm.DateTime"; - case "smallint": return "Edm.Int16"; - case "smallmoney": return "Edm.Decimal"; - case "sql_variant": return "Edm.Object"; - case "text": return "Edm.String"; - case "time": return "Edm.TimeSpan"; - case "timestamp": return "Edm.Byte[]"; - case "tinyint": return "Edm.Byte"; - case "uniqueidentifier": return "Edm.Guid"; - case "varbinary": return "Edm.Byte[]"; - case "varchar": return "Edm.String"; - case "xml": return "Edm.Xml"; - default: throw new ArgumentException("Unsupported type", "sqlType"); - } - } - - private string ODataMetaData(TableSpec spec, string Namespace, string EntityName) - { - var metadata = new StringBuilder(); - metadata - .AppendFormat(@" - - - ", Namespace) - .AppendFormat(@"", EntityName); - for(int i = 0; i< spec.columns.Count; i++) - { - if(i == 0) - metadata.AppendFormat(@"", spec.columns[0]); - metadata.AppendFormat(@"", spec.columns[i], "Edm.Int32"); - } - - metadata - .AppendFormat(@"") - //.Append("") - //.AppendFormat(@"") - .AppendFormat(@" - - - - ", "DefaultContainer", EntityName, "Models.Product") - .AppendFormat(@" - - "); - - return metadata.ToString(); - } } } \ No newline at end of file