read url from app.config
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
8
API/API.Client.Test/App.config
Normal file
8
API/API.Client.Test/App.config
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="url" value="http://localhost/API"/>
|
||||
<!--<add key="url" value="http://test.benjamin-ifland.de"/>-->
|
||||
</appSettings>
|
||||
|
||||
</configuration>
|
||||
@@ -59,6 +59,7 @@
|
||||
<HintPath>..\packages\Simple.OData.Client.5.6.2\lib\net452\Simple.OData.Client.V4.Adapter.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Spatial, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Spatial.5.8.4\lib\net40\System.Spatial.dll</HintPath>
|
||||
|
||||
@@ -3,38 +3,40 @@ using API.Models;
|
||||
using Simple.OData.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace API.Client {
|
||||
public class Client {
|
||||
private static string url = ConfigurationManager.AppSettings["url"] + "/odata";
|
||||
|
||||
public async Task<IEnumerable<Song>> Get() {
|
||||
var client = new ODataClient("http://localhost/API/odata").For<Song>();
|
||||
var client = new ODataClient(url).For<Song>();
|
||||
var songs = await client.FindEntriesAsync();
|
||||
return songs;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Song>> Get(Expression<Func<Song, bool>> filterExpression) {
|
||||
var client = new ODataClient("http://localhost/API/odata").For<Song>();
|
||||
var client = new ODataClient(url).For<Song>();
|
||||
var songs = await client.Filter(filterExpression).FindEntriesAsync();
|
||||
return songs;
|
||||
}
|
||||
|
||||
public async Task<Song> Get(long id) {
|
||||
var client = new ODataClient("http://localhost/API/odata").For<Song>();
|
||||
var client = new ODataClient(url).For<Song>();
|
||||
var song = await client.Key(id).FindEntryAsync();
|
||||
return song;
|
||||
}
|
||||
|
||||
public async Task<Song> Post(Song song) {
|
||||
var client = new ODataClient("http://localhost/API/odata").For<Song>();
|
||||
var client = new ODataClient(url).For<Song>();
|
||||
var insertedSong = await client.Set(song).InsertEntryAsync();
|
||||
return insertedSong;
|
||||
}
|
||||
|
||||
public async Task<int> Delete(long id) {
|
||||
var client = new ODataClient("http://localhost/API/odata").For<Song>();
|
||||
var client = new ODataClient(url).For<Song>();
|
||||
var count = await client.Key(id).DeleteEntriesAsync();
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\PublishProfiles\CustomProfile.pubxml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Migrations\201903161558469_Init.resx">
|
||||
|
||||
21
API/API/Properties/PublishProfiles/CustomProfile.pubxml
Normal file
21
API/API/Properties/PublishProfiles/CustomProfile.pubxml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
|
||||
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<WebPublishMethod>FTP</WebPublishMethod>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||
<ExcludeApp_Data>True</ExcludeApp_Data>
|
||||
<publishUrl>home472178787.1and1-data.host</publishUrl>
|
||||
<DeleteExistingFiles>False</DeleteExistingFiles>
|
||||
<FtpPassiveMode>True</FtpPassiveMode>
|
||||
<FtpSitePath>test</FtpSitePath>
|
||||
<UserName>u73527913</UserName>
|
||||
<_SavePWD>False</_SavePWD>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user