init database
This commit is contained in:
@@ -101,9 +101,22 @@
|
||||
<Compile Include="App_Start\Bootstrapper.cs" />
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="Controllers\ValuesController.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>
|
||||
<Compile Include="Migrations\201903161558469_Init.cs" />
|
||||
<Compile Include="Migrations\201903161558469_Init.Designer.cs">
|
||||
<DependentUpon>201903161558469_Init.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\Configuration.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -123,6 +136,11 @@
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Migrations\201903161558469_Init.resx">
|
||||
<DependentUpon>201903161558469_Init.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
||||
11
API/API/Database/DataContext.cs
Normal file
11
API/API/Database/DataContext.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using API.Database.Model;
|
||||
using System.Data.Entity;
|
||||
|
||||
namespace API.Database {
|
||||
public class DataContext : DbContext {
|
||||
public DbSet<Song> Songs { get; set; }
|
||||
public DbSet<Change> Changes { get; set; }
|
||||
public DbSet<File> Files { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
}
|
||||
}
|
||||
8
API/API/Database/Model/Access.cs
Normal file
8
API/API/Database/Model/Access.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace API.Database.Model {
|
||||
public enum Access {
|
||||
Inactive,
|
||||
Reader,
|
||||
Writer,
|
||||
Admin
|
||||
}
|
||||
}
|
||||
11
API/API/Database/Model/Change.cs
Normal file
11
API/API/Database/Model/Change.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
10
API/API/Database/Model/File.cs
Normal file
10
API/API/Database/Model/File.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
8
API/API/Database/Model/FileType.cs
Normal file
8
API/API/Database/Model/FileType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace API.Database.Model {
|
||||
public enum FileType {
|
||||
None,
|
||||
Sheet,
|
||||
Chords,
|
||||
MuseScore
|
||||
}
|
||||
}
|
||||
17
API/API/Database/Model/Song.cs
Normal file
17
API/API/Database/Model/Song.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
7
API/API/Database/Model/SongType.cs
Normal file
7
API/API/Database/Model/SongType.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace API.Database.Model {
|
||||
public enum SongType {
|
||||
Praise,
|
||||
Worship
|
||||
}
|
||||
|
||||
}
|
||||
11
API/API/Database/Model/User.cs
Normal file
11
API/API/Database/Model/User.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
29
API/API/Migrations/201903161558469_Init.Designer.cs
generated
Normal file
29
API/API/Migrations/201903161558469_Init.Designer.cs
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
// <auto-generated />
|
||||
namespace API.Migrations
|
||||
{
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Data.Entity.Migrations.Infrastructure;
|
||||
using System.Resources;
|
||||
|
||||
[GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
|
||||
public sealed partial class Init : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(Init));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "201903161558469_Init"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
71
API/API/Migrations/201903161558469_Init.cs
Normal file
71
API/API/Migrations/201903161558469_Init.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
namespace API.Migrations {
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class Init : DbMigration {
|
||||
public override void Up() {
|
||||
CreateTable(
|
||||
"dbo.Changes",
|
||||
c => new {
|
||||
ID = c.Int(nullable: false, identity: true),
|
||||
UserId = c.Int(nullable: false),
|
||||
Date = c.DateTime(nullable: false),
|
||||
Comment = c.String(),
|
||||
Song_ID = c.Int(),
|
||||
})
|
||||
.PrimaryKey(t => t.ID)
|
||||
.ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true)
|
||||
.ForeignKey("dbo.Songs", t => t.Song_ID)
|
||||
.Index(t => t.UserId)
|
||||
.Index(t => t.Song_ID);
|
||||
|
||||
CreateTable(
|
||||
"dbo.Users",
|
||||
c => new {
|
||||
ID = c.Int(nullable: false, identity: true),
|
||||
Account = c.String(),
|
||||
Pass = c.String(),
|
||||
Name = c.String(),
|
||||
Surname = c.String(),
|
||||
Email = c.String(),
|
||||
Access = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.ID);
|
||||
|
||||
CreateTable(
|
||||
"dbo.Files",
|
||||
c => new {
|
||||
ID = c.Int(nullable: false, identity: true),
|
||||
ReferenceFile = c.Guid(nullable: false),
|
||||
Name = c.String(),
|
||||
FileType = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.ID);
|
||||
|
||||
CreateTable(
|
||||
"dbo.Songs",
|
||||
c => new {
|
||||
ID = c.Int(nullable: false, identity: true),
|
||||
Name = c.String(),
|
||||
Text = c.String(),
|
||||
Comments = c.String(),
|
||||
Key = c.String(),
|
||||
Tempo = c.Int(),
|
||||
SongType = c.Int(nullable: false),
|
||||
Final = c.Boolean(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.ID);
|
||||
|
||||
}
|
||||
|
||||
public override void Down() {
|
||||
DropForeignKey("dbo.Changes", "Song_ID", "dbo.Songs");
|
||||
DropForeignKey("dbo.Changes", "UserId", "dbo.Users");
|
||||
DropIndex("dbo.Changes", new[] { "Song_ID" });
|
||||
DropIndex("dbo.Changes", new[] { "UserId" });
|
||||
DropTable("dbo.Songs");
|
||||
DropTable("dbo.Files");
|
||||
DropTable("dbo.Users");
|
||||
DropTable("dbo.Changes");
|
||||
}
|
||||
}
|
||||
}
|
||||
126
API/API/Migrations/201903161558469_Init.resx
Normal file
126
API/API/Migrations/201903161558469_Init.resx
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Target" xml:space="preserve">
|
||||
<value>H4sIAAAAAAAEAO1bW2/bNhR+H7D/IOhpG1IrSV+2wG6ROklhrLkgTtu9FYzEOMQkyhOpIMGwX7aH/aT9hR2KuvAmW7JityuKAYVD8Xwkz42H55z9+/c/49ePSew94IyRlE78g9G+72EaphGhi4mf87sX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FvXK/rrCvQ8uMzqxBclK7rwYBqb0CwzRH76IahKV1Sg1C0ruhCrE+YxfU16GXzk6knJI/ckwKzDsiEs8DupIGidDsPHpGIdpPmf+tEJ+N3WpfzyAgs3dnEJjSnzPwdEoPjqFJXe/HfsroUmilD+eWbKrNm5WsZRFplzVls360UYl8o8J0S4J3S6Xor6j8PLTevGtBt2SyPqegVzzfn13S7gK8XYxrSSrqL7r2Crt88sJD5VZ4UOmv2kqgrvJ7a/XdBewuJrsK8611eRdsWcnvULJvrdi7YJ215C0W81V2NkWp9bV7R/n6yyrYWxX6rR+qR0nezhaB0Sr/CyT4C0YWDYTIf1EcauZaz5nRu7RyG8aOqilG3HCOOYrAlo8zCMlRyOGzeNwUzcplr9tpcoujGb3M+TLncGSc3MZaill4n1XrF30H+p7Hl8uiu/c5jgDbJCLPcUnf5CSO6n2fOcKeFgjh1sq4WciSi/h58VQjybbNLkAl+2pvLELDGMDYJZ0jpQe3x97ACt/hBQqfqqRfO8h6QehsH58QtMhQwkqMhh7+BB2OksdX/wHka3UgCTwAAA==</value>
|
||||
</data>
|
||||
<data name="DefaultSchema" xml:space="preserve">
|
||||
<value>dbo</value>
|
||||
</data>
|
||||
</root>
|
||||
9
API/API/Migrations/Configuration.cs
Normal file
9
API/API/Migrations/Configuration.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace API.Migrations {
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
internal sealed class Configuration : DbMigrationsConfiguration<Database.DataContext> {
|
||||
public Configuration() {
|
||||
AutomaticMigrationsEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user