creating oData client
testing odata interface
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<AssemblyName>API</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
<Use64BitIISExpress />
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
@@ -130,13 +130,6 @@
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="Controllers\SongsController.cs" />
|
||||
<Compile Include="Database\DataContext.cs" />
|
||||
<Compile Include="Database\Model\Access.cs" />
|
||||
<Compile Include="Database\Model\Change.cs" />
|
||||
<Compile Include="Database\Model\File.cs" />
|
||||
<Compile Include="Database\Model\FileType.cs" />
|
||||
<Compile Include="Database\Model\Song.cs" />
|
||||
<Compile Include="Database\Model\SongType.cs" />
|
||||
<Compile Include="Database\Model\User.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
@@ -160,7 +153,12 @@
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Models\API.Models.csproj">
|
||||
<Project>{8d72ff7d-c085-4c06-9d66-9537b7ac924d}</Project>
|
||||
<Name>API.Models</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
@@ -187,7 +185,7 @@
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>50752</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:50752/</IISUrl>
|
||||
<IISUrl>http://localhost/API</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using API.App_Start;
|
||||
using API.Database.Model;
|
||||
using API.Models;
|
||||
using Microsoft.AspNet.OData.Builder;
|
||||
using Microsoft.AspNet.OData.Extensions;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -22,6 +22,7 @@ namespace API {
|
||||
// Web API oData configuration
|
||||
var builder = new ODataConventionModelBuilder();
|
||||
builder.EntitySet<Song>("songs");
|
||||
config.Count().Filter().OrderBy().Expand().Select().MaxTop(null);
|
||||
config.MapODataServiceRoute(
|
||||
routeName: "songs",
|
||||
routePrefix: "odata",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using API.Database;
|
||||
using API.Database.Model;
|
||||
using API.Models;
|
||||
using Microsoft.AspNet.OData;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
namespace ProductService.Controllers {
|
||||
@@ -73,6 +74,15 @@ namespace ProductService.Controllers {
|
||||
return Updated(update);
|
||||
}
|
||||
|
||||
public async Task<IHttpActionResult> Delete([FromODataUri] int key) {
|
||||
var product = await db.Songs.FindAsync(key);
|
||||
if (product == null) {
|
||||
return NotFound();
|
||||
}
|
||||
db.Songs.Remove(product);
|
||||
await db.SaveChangesAsync();
|
||||
return StatusCode(HttpStatusCode.NoContent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
using API.Database.Model;
|
||||
using API.Models;
|
||||
using System.Data.Entity;
|
||||
|
||||
namespace API.Database {
|
||||
public class DataContext : DbContext {
|
||||
|
||||
public DataContext() : base("DataContext") { }
|
||||
|
||||
public DbSet<Song> Songs { get; set; }
|
||||
public DbSet<Change> Changes { get; set; }
|
||||
public DbSet<File> Files { get; set; }
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace API.Database.Model {
|
||||
public enum Access {
|
||||
Inactive,
|
||||
Reader,
|
||||
Writer,
|
||||
Admin
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace API.Database.Model {
|
||||
public class Change {
|
||||
public int ID { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public string Comment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace API.Database.Model {
|
||||
public class File {
|
||||
public int ID { get; set; }
|
||||
public Guid ReferenceFile { get; set; }
|
||||
public string Name { get; set; }
|
||||
public FileType FileType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace API.Database.Model {
|
||||
public enum FileType {
|
||||
None,
|
||||
Sheet,
|
||||
Chords,
|
||||
MuseScore
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace API.Database.Model {
|
||||
public class Song {
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Text { get; set; }
|
||||
public string Comments { get; set; }
|
||||
public string Key { get; set; }
|
||||
public int? Tempo { get; set; }
|
||||
public SongType SongType { get; set; }
|
||||
|
||||
public bool Final { get; set; }
|
||||
|
||||
public virtual ICollection<Change> Changes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace API.Database.Model {
|
||||
public enum SongType {
|
||||
Praise,
|
||||
Worship
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace API.Database.Model {
|
||||
public class User {
|
||||
public int ID { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string Pass { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Surname { get; set; }
|
||||
public string Email { get; set; }
|
||||
public Access Access { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<connectionStrings>
|
||||
<add name="DataContext" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=wgenerator;Integrated Security=True;User ID=sa;Password=sa" providerName="System.Data.SqlClient" />
|
||||
<add name="DataContext" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=wgenerator;User ID=sa;Password=sa" providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
<appSettings>
|
||||
<add key="webpages:Version" value="3.0.0.0" />
|
||||
|
||||
Reference in New Issue
Block a user