diff --git a/data/createdatabase.sql b/data/createdatabase.sql
index 41b5a17..71e014e 100644
--- a/data/createdatabase.sql
+++ b/data/createdatabase.sql
@@ -1,115 +1,115 @@
USE [master]
GO
-/****** Object: Database [sql101.firstname.lastname] Script Date: 1/21/2019 9:11:50 PM ******/
-CREATE DATABASE [sql101.firstname.lastname]
+/****** Object: Database [sql101.ilze.lourens] Script Date: 1/21/2019 9:11:50 PM ******/
+CREATE DATABASE [sql101.ilze.lourens]
CONTAINMENT = NONE
ON PRIMARY
-( NAME = N'sql101.firstname.lastname', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\sql101.firstname.lastname.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
+( NAME = N'sql101.ilze.lourens', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\sql101.ilze.lourens.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
-( NAME = N'sql101.firstname.lastname_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\sql101.firstname.lastname_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
+( NAME = N'sql101.ilze.lourens_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\sql101.ilze.lourens_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO
-ALTER DATABASE [sql101.firstname.lastname] SET COMPATIBILITY_LEVEL = 130
+ALTER DATABASE [sql101.ilze.lourens] SET COMPATIBILITY_LEVEL = 130
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
-EXEC [sql101.firstname.lastname].[dbo].[sp_fulltext_database] @action = 'enable'
+EXEC [sql101.ilze.lourens].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
-ALTER DATABASE [sql101.firstname.lastname] SET ANSI_NULL_DEFAULT OFF
+ALTER DATABASE [sql101.ilze.lourens] SET ANSI_NULL_DEFAULT OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET ANSI_NULLS OFF
+ALTER DATABASE [sql101.ilze.lourens] SET ANSI_NULLS OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET ANSI_PADDING OFF
+ALTER DATABASE [sql101.ilze.lourens] SET ANSI_PADDING OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET ANSI_WARNINGS OFF
+ALTER DATABASE [sql101.ilze.lourens] SET ANSI_WARNINGS OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET ARITHABORT OFF
+ALTER DATABASE [sql101.ilze.lourens] SET ARITHABORT OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET AUTO_CLOSE OFF
+ALTER DATABASE [sql101.ilze.lourens] SET AUTO_CLOSE OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET AUTO_SHRINK OFF
+ALTER DATABASE [sql101.ilze.lourens] SET AUTO_SHRINK OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET AUTO_UPDATE_STATISTICS ON
+ALTER DATABASE [sql101.ilze.lourens] SET AUTO_UPDATE_STATISTICS ON
GO
-ALTER DATABASE [sql101.firstname.lastname] SET CURSOR_CLOSE_ON_COMMIT OFF
+ALTER DATABASE [sql101.ilze.lourens] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET CURSOR_DEFAULT GLOBAL
+ALTER DATABASE [sql101.ilze.lourens] SET CURSOR_DEFAULT GLOBAL
GO
-ALTER DATABASE [sql101.firstname.lastname] SET CONCAT_NULL_YIELDS_NULL OFF
+ALTER DATABASE [sql101.ilze.lourens] SET CONCAT_NULL_YIELDS_NULL OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET NUMERIC_ROUNDABORT OFF
+ALTER DATABASE [sql101.ilze.lourens] SET NUMERIC_ROUNDABORT OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET QUOTED_IDENTIFIER OFF
+ALTER DATABASE [sql101.ilze.lourens] SET QUOTED_IDENTIFIER OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET RECURSIVE_TRIGGERS OFF
+ALTER DATABASE [sql101.ilze.lourens] SET RECURSIVE_TRIGGERS OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET DISABLE_BROKER
+ALTER DATABASE [sql101.ilze.lourens] SET DISABLE_BROKER
GO
-ALTER DATABASE [sql101.firstname.lastname] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
+ALTER DATABASE [sql101.ilze.lourens] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET DATE_CORRELATION_OPTIMIZATION OFF
+ALTER DATABASE [sql101.ilze.lourens] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET TRUSTWORTHY OFF
+ALTER DATABASE [sql101.ilze.lourens] SET TRUSTWORTHY OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET ALLOW_SNAPSHOT_ISOLATION OFF
+ALTER DATABASE [sql101.ilze.lourens] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET PARAMETERIZATION SIMPLE
+ALTER DATABASE [sql101.ilze.lourens] SET PARAMETERIZATION SIMPLE
GO
-ALTER DATABASE [sql101.firstname.lastname] SET READ_COMMITTED_SNAPSHOT OFF
+ALTER DATABASE [sql101.ilze.lourens] SET READ_COMMITTED_SNAPSHOT OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET HONOR_BROKER_PRIORITY OFF
+ALTER DATABASE [sql101.ilze.lourens] SET HONOR_BROKER_PRIORITY OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET RECOVERY FULL
+ALTER DATABASE [sql101.ilze.lourens] SET RECOVERY FULL
GO
-ALTER DATABASE [sql101.firstname.lastname] SET MULTI_USER
+ALTER DATABASE [sql101.ilze.lourens] SET MULTI_USER
GO
-ALTER DATABASE [sql101.firstname.lastname] SET PAGE_VERIFY CHECKSUM
+ALTER DATABASE [sql101.ilze.lourens] SET PAGE_VERIFY CHECKSUM
GO
-ALTER DATABASE [sql101.firstname.lastname] SET DB_CHAINING OFF
+ALTER DATABASE [sql101.ilze.lourens] SET DB_CHAINING OFF
GO
-ALTER DATABASE [sql101.firstname.lastname] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
+ALTER DATABASE [sql101.ilze.lourens] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
-ALTER DATABASE [sql101.firstname.lastname] SET TARGET_RECOVERY_TIME = 60 SECONDS
+ALTER DATABASE [sql101.ilze.lourens] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
-ALTER DATABASE [sql101.firstname.lastname] SET DELAYED_DURABILITY = DISABLED
+ALTER DATABASE [sql101.ilze.lourens] SET DELAYED_DURABILITY = DISABLED
GO
-ALTER DATABASE [sql101.firstname.lastname] SET QUERY_STORE = OFF
+ALTER DATABASE [sql101.ilze.lourens] SET QUERY_STORE = OFF
GO
-USE [sql101.firstname.lastname]
+USE [sql101.ilze.lourens]
GO
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION = OFF;
@@ -124,7 +124,7 @@ GO
ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF;
GO
-ALTER DATABASE [sql101.firstname.lastname] SET READ_WRITE
+ALTER DATABASE [sql101.ilze.lourens] SET READ_WRITE
GO
diff --git a/data/createuser.sql b/data/createuser.sql
index bcf3038..8e36947 100644
--- a/data/createuser.sql
+++ b/data/createuser.sql
@@ -1,18 +1,18 @@
USE [master]
GO
-CREATE LOGIN [firstnamelastname] WITH PASSWORD=N'rabbit123!@#' MUST_CHANGE, DEFAULT_DATABASE=[sql101.firstname.lastname], CHECK_EXPIRATION=ON, CHECK_POLICY=ON
+CREATE LOGIN [ilzelourens] WITH PASSWORD=N'rabbit123!@#' MUST_CHANGE, DEFAULT_DATABASE=[sql101.ilze.lourens], CHECK_EXPIRATION=ON, CHECK_POLICY=ON
GO
-use [sql101.firstname.lastname]
+use [sql101.ilze.lourens]
GO
use [master]
GO
-USE [sql101.firstname.lastname]
+USE [sql101.ilze.lourens]
GO
-CREATE USER [firstnamelastname] FOR LOGIN [firstnamelastname]
+CREATE USER [ilzelourens] FOR LOGIN [ilzelourens]
GO
-USE [sql101.firstname.lastname]
+USE [sql101.ilze.lourens]
GO
-ALTER ROLE [db_owner] ADD MEMBER [firstnamelastname]
+ALTER ROLE [db_owner] ADD MEMBER [ilzelourens]
GO
diff --git a/src/MyTimesheet/MyTimesheet/CacheSecrets.config b/src/MyTimesheet/MyTimesheet/CacheSecrets.config
new file mode 100644
index 0000000..79ee1f4
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/CacheSecrets.config
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MyTimesheet/MyTimesheet/Controllers/TimesheetController.cs b/src/MyTimesheet/MyTimesheet/Controllers/TimesheetController.cs
index b2f5a7c..a6addd0 100644
--- a/src/MyTimesheet/MyTimesheet/Controllers/TimesheetController.cs
+++ b/src/MyTimesheet/MyTimesheet/Controllers/TimesheetController.cs
@@ -1,6 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using Microsoft.IdentityModel.Protocols;
+using MyTimesheet.Interfaces;
using MyTimesheet.Models;
+using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,31 +17,55 @@ namespace MyTimesheet.Controllers
public class TimesheetController : ControllerBase
{
private readonly TimesheetContext _db;
- public TimesheetController(TimesheetContext context)
+ readonly IConfiguration _config;
+ private RediProviderInterface _redisPovider;
+ public TimesheetController(TimesheetContext context, IConfiguration config, RediProviderInterface redisProvider)
{
_db = context;
+ _config = config;
+ _redisPovider = redisProvider;
}
// GET api/values
[HttpGet]
public async Task>> Get()
{
- return await _db.Entries.ToListAsync();
+
+ var EntriesList = await _db.Entries.ToListAsync();
+ foreach(var entry in EntriesList)
+ {
+ entry.person = await _db.Person.FindAsync(entry.personId);
+ entry.date = await _db.Date.FindAsync(entry.dateId);
+ entry.client = await _db.Client.FindAsync(entry.clientIid);
+ }
+ return EntriesList;
}
// GET api/values/5
[HttpGet("{id}")]
public async Task> Get(int id)
{
- return await _db.Entries.FindAsync(id);
+ var entry = await _db.Entries.FindAsync(id);
+ entry.person = await _db.Person.FindAsync(entry.personId);
+ entry.date = await _db.Date.FindAsync(entry.dateId);
+ entry.client = await _db.Client.FindAsync(entry.clientIid);
+ var thisOne = _redisPovider.GetAsync($"{entry.person.Name}-{entry.person.Surname}");
+ return entry;
+
}
// POST api/values
[HttpPost]
- public async Task Post([FromBody] TimesheetEntry value)
+ public async Task Post([FromBody] TimesheetEntry value)
{
await _db.Entries.AddAsync(value);
await _db.SaveChangesAsync();
+
+
+ var Saved = await _redisPovider.SaveAsync($"{value.person.Name}-{value.person.Surname}", value);
+ if (Saved)
+ return "Sucesfully saved to redis";
+ else return "Failed to save to reis";
}
// PUT api/values/5
@@ -47,6 +75,9 @@ public async Task Put(int id, [FromBody] TimesheetEntry value)
var entry = await _db.Entries.FindAsync(id);
entry = value;
await _db.SaveChangesAsync();
+ var Saved = await _redisPovider.SaveAsync($"{entry.person.Name}-{entry.person.Surname}", value);
+
+
}
// DELETE api/values/5
diff --git a/src/MyTimesheet/MyTimesheet/Interfaces/RediProviderInterface.cs b/src/MyTimesheet/MyTimesheet/Interfaces/RediProviderInterface.cs
new file mode 100644
index 0000000..808d7ce
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Interfaces/RediProviderInterface.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MyTimesheet.Interfaces
+{
+ public interface RediProviderInterface
+ {
+ Task SaveAsync(string key, object obj);
+ Task GetAsync(string Key);
+
+
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190122085428_InitialCreate.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190122085428_InitialCreate.Designer.cs
new file mode 100644
index 0000000..c1a94f8
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190122085428_InitialCreate.Designer.cs
@@ -0,0 +1,57 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ [Migration("20190122085428_InitialCreate")]
+ partial class InitialCreate
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Client");
+
+ b.Property("Date");
+
+ b.Property("Description");
+
+ b.Property("Duration");
+
+ b.Property("Name");
+
+ b.Property("Project");
+
+ b.Property("Surname");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.HasKey("Id");
+
+ b.ToTable("Entries");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190122085428_InitialCreate.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190122085428_InitialCreate.cs
new file mode 100644
index 0000000..f49fcb6
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190122085428_InitialCreate.cs
@@ -0,0 +1,40 @@
+using System;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace MyTimesheet.Migrations
+{
+ public partial class InitialCreate : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Entries",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+ Name = table.Column(nullable: true),
+ Surname = table.Column(nullable: true),
+ Client = table.Column(nullable: true),
+ Project = table.Column(nullable: true),
+ Date = table.Column(nullable: false),
+ TimeStart = table.Column(nullable: false),
+ TimeEnd = table.Column(nullable: false),
+ Duration = table.Column(nullable: false),
+ Description = table.Column(nullable: true),
+ Billable = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Entries", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Entries");
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190125192433_addDateTable.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190125192433_addDateTable.Designer.cs
new file mode 100644
index 0000000..f9d3909
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190125192433_addDateTable.Designer.cs
@@ -0,0 +1,76 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ [Migration("20190125192433_addDateTable")]
+ partial class addDateTable
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.Date", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Duration");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.Property("date");
+
+ b.HasKey("Id");
+
+ b.ToTable("Date");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Client");
+
+ b.Property("Date");
+
+ b.Property("Description");
+
+ b.Property("Duration");
+
+ b.Property("Name");
+
+ b.Property("Project");
+
+ b.Property("Surname");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.HasKey("Id");
+
+ b.ToTable("Entries");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190125192433_addDateTable.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190125192433_addDateTable.cs
new file mode 100644
index 0000000..981caaf
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190125192433_addDateTable.cs
@@ -0,0 +1,34 @@
+using System;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace MyTimesheet.Migrations
+{
+ public partial class addDateTable : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Date",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+ date = table.Column(nullable: false),
+ TimeStart = table.Column(nullable: false),
+ TimeEnd = table.Column(nullable: false),
+ Duration = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Date", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Date");
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126073513_TestAddingTableAsField.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126073513_TestAddingTableAsField.Designer.cs
new file mode 100644
index 0000000..f89b3be
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126073513_TestAddingTableAsField.Designer.cs
@@ -0,0 +1,79 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ [Migration("20190126073513_TestAddingTableAsField")]
+ partial class TestAddingTableAsField
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.Date", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Duration");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.Property("date");
+
+ b.HasKey("Id");
+
+ b.ToTable("Date");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Client");
+
+ b.Property("Description");
+
+ b.Property("Name");
+
+ b.Property("Project");
+
+ b.Property("Surname");
+
+ b.Property("dateId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("dateId");
+
+ b.ToTable("Entries");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.HasOne("MyTimesheet.Models.Date", "date")
+ .WithMany()
+ .HasForeignKey("dateId");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126073513_TestAddingTableAsField.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126073513_TestAddingTableAsField.cs
new file mode 100644
index 0000000..5ff5cb2
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126073513_TestAddingTableAsField.cs
@@ -0,0 +1,84 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace MyTimesheet.Migrations
+{
+ public partial class TestAddingTableAsField : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Date",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "Duration",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "TimeEnd",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "TimeStart",
+ table: "Entries");
+
+ migrationBuilder.AddColumn(
+ name: "dateId",
+ table: "Entries",
+ nullable: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Entries_dateId",
+ table: "Entries",
+ column: "dateId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Entries_Date_dateId",
+ table: "Entries",
+ column: "dateId",
+ principalTable: "Date",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Entries_Date_dateId",
+ table: "Entries");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Entries_dateId",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "dateId",
+ table: "Entries");
+
+ migrationBuilder.AddColumn(
+ name: "Date",
+ table: "Entries",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "Duration",
+ table: "Entries",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "TimeEnd",
+ table: "Entries",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "TimeStart",
+ table: "Entries",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126074748_NormalizedTables.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126074748_NormalizedTables.Designer.cs
new file mode 100644
index 0000000..f0fc45d
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126074748_NormalizedTables.Designer.cs
@@ -0,0 +1,79 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ [Migration("20190126074748_NormalizedTables")]
+ partial class NormalizedTables
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.Date", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Duration");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.Property("date");
+
+ b.HasKey("Id");
+
+ b.ToTable("Date");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Client");
+
+ b.Property("Description");
+
+ b.Property("Name");
+
+ b.Property("Project");
+
+ b.Property("Surname");
+
+ b.Property("dateId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("dateId");
+
+ b.ToTable("Entries");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.HasOne("MyTimesheet.Models.Date", "date")
+ .WithMany()
+ .HasForeignKey("dateId");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126074748_NormalizedTables.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126074748_NormalizedTables.cs
new file mode 100644
index 0000000..42e33a2
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126074748_NormalizedTables.cs
@@ -0,0 +1,17 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace MyTimesheet.Migrations
+{
+ public partial class NormalizedTables : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126074936_CreateTables.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126074936_CreateTables.Designer.cs
new file mode 100644
index 0000000..870b919
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126074936_CreateTables.Designer.cs
@@ -0,0 +1,115 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ [Migration("20190126074936_CreateTables")]
+ partial class CreateTables
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Project")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.Property("client")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Client");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Date", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Duration");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.Property("date");
+
+ b.HasKey("Id");
+
+ b.ToTable("Date");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Name")
+ .HasMaxLength(30);
+
+ b.Property("Surname")
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Person");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Client");
+
+ b.Property("Description");
+
+ b.Property("Name");
+
+ b.Property("Project");
+
+ b.Property("Surname");
+
+ b.Property("dateId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("dateId");
+
+ b.ToTable("Entries");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.HasOne("MyTimesheet.Models.Date", "date")
+ .WithMany()
+ .HasForeignKey("dateId");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126074936_CreateTables.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126074936_CreateTables.cs
new file mode 100644
index 0000000..0ccb4a3
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126074936_CreateTables.cs
@@ -0,0 +1,48 @@
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace MyTimesheet.Migrations
+{
+ public partial class CreateTables : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Client",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+ client = table.Column(maxLength: 30, nullable: false),
+ Project = table.Column(maxLength: 30, nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Client", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Person",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+ Name = table.Column(maxLength: 30, nullable: true),
+ Surname = table.Column(maxLength: 30, nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Person", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Client");
+
+ migrationBuilder.DropTable(
+ name: "Person");
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126075315_UpdateTimesheetEntryTable.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126075315_UpdateTimesheetEntryTable.Designer.cs
new file mode 100644
index 0000000..16c2ce5
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126075315_UpdateTimesheetEntryTable.Designer.cs
@@ -0,0 +1,123 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ [Migration("20190126075315_UpdateTimesheetEntryTable")]
+ partial class UpdateTimesheetEntryTable
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Project")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.Property("client")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Client");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Date", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Duration");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.Property("date");
+
+ b.HasKey("Id");
+
+ b.ToTable("Date");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Name")
+ .HasMaxLength(30);
+
+ b.Property("Surname")
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Person");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Description");
+
+ b.Property("clientId");
+
+ b.Property("dateId");
+
+ b.Property("personId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("clientId");
+
+ b.HasIndex("dateId");
+
+ b.HasIndex("personId");
+
+ b.ToTable("Entries");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.HasOne("MyTimesheet.Models.Client", "client")
+ .WithMany()
+ .HasForeignKey("clientId");
+
+ b.HasOne("MyTimesheet.Models.Date", "date")
+ .WithMany()
+ .HasForeignKey("dateId");
+
+ b.HasOne("MyTimesheet.Models.Person", "person")
+ .WithMany()
+ .HasForeignKey("personId");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126075315_UpdateTimesheetEntryTable.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126075315_UpdateTimesheetEntryTable.cs
new file mode 100644
index 0000000..3a83cef
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126075315_UpdateTimesheetEntryTable.cs
@@ -0,0 +1,109 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace MyTimesheet.Migrations
+{
+ public partial class UpdateTimesheetEntryTable : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Client",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "Name",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "Project",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "Surname",
+ table: "Entries");
+
+ migrationBuilder.AddColumn(
+ name: "clientId",
+ table: "Entries",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "personId",
+ table: "Entries",
+ nullable: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Entries_clientId",
+ table: "Entries",
+ column: "clientId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Entries_personId",
+ table: "Entries",
+ column: "personId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Entries_Client_clientId",
+ table: "Entries",
+ column: "clientId",
+ principalTable: "Client",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Entries_Person_personId",
+ table: "Entries",
+ column: "personId",
+ principalTable: "Person",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Entries_Client_clientId",
+ table: "Entries");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Entries_Person_personId",
+ table: "Entries");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Entries_clientId",
+ table: "Entries");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Entries_personId",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "clientId",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "personId",
+ table: "Entries");
+
+ migrationBuilder.AddColumn(
+ name: "Client",
+ table: "Entries",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "Name",
+ table: "Entries",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "Project",
+ table: "Entries",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "Surname",
+ table: "Entries",
+ nullable: true);
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126121157_TestPersonId.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126121157_TestPersonId.Designer.cs
new file mode 100644
index 0000000..52ddfcc
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126121157_TestPersonId.Designer.cs
@@ -0,0 +1,124 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ [Migration("20190126121157_TestPersonId")]
+ partial class TestPersonId
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Project")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.Property("client")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Client");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Date", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Duration");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.Property("date");
+
+ b.HasKey("Id");
+
+ b.ToTable("Date");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Name")
+ .HasMaxLength(30);
+
+ b.Property("Surname")
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Person");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Description");
+
+ b.Property("clientId");
+
+ b.Property("dateId");
+
+ b.Property("personId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("clientId");
+
+ b.HasIndex("dateId");
+
+ b.HasIndex("personId");
+
+ b.ToTable("Entries");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.HasOne("MyTimesheet.Models.Client", "client")
+ .WithMany()
+ .HasForeignKey("clientId");
+
+ b.HasOne("MyTimesheet.Models.Date", "date")
+ .WithMany()
+ .HasForeignKey("dateId");
+
+ b.HasOne("MyTimesheet.Models.Person", "person")
+ .WithMany()
+ .HasForeignKey("personId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126121157_TestPersonId.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126121157_TestPersonId.cs
new file mode 100644
index 0000000..0e7ba74
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126121157_TestPersonId.cs
@@ -0,0 +1,50 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace MyTimesheet.Migrations
+{
+ public partial class TestPersonId : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Entries_Person_personId",
+ table: "Entries");
+
+ migrationBuilder.AlterColumn(
+ name: "personId",
+ table: "Entries",
+ nullable: false,
+ oldClrType: typeof(int),
+ oldNullable: true);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Entries_Person_personId",
+ table: "Entries",
+ column: "personId",
+ principalTable: "Person",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Entries_Person_personId",
+ table: "Entries");
+
+ migrationBuilder.AlterColumn(
+ name: "personId",
+ table: "Entries",
+ nullable: true,
+ oldClrType: typeof(int));
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Entries_Person_personId",
+ table: "Entries",
+ column: "personId",
+ principalTable: "Person",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126121407_ForeignKeys.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126121407_ForeignKeys.Designer.cs
new file mode 100644
index 0000000..d858fb4
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126121407_ForeignKeys.Designer.cs
@@ -0,0 +1,127 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ [Migration("20190126121407_ForeignKeys")]
+ partial class ForeignKeys
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Project")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.Property("client")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Client");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Date", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Duration");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.Property("date");
+
+ b.HasKey("Id");
+
+ b.ToTable("Date");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Name")
+ .HasMaxLength(30);
+
+ b.Property("Surname")
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Person");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Description");
+
+ b.Property("clientId");
+
+ b.Property("clientIid");
+
+ b.Property("dateId");
+
+ b.Property("personId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("clientId");
+
+ b.HasIndex("dateId");
+
+ b.HasIndex("personId");
+
+ b.ToTable("Entries");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.HasOne("MyTimesheet.Models.Client", "client")
+ .WithMany()
+ .HasForeignKey("clientId");
+
+ b.HasOne("MyTimesheet.Models.Date", "date")
+ .WithMany()
+ .HasForeignKey("dateId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("MyTimesheet.Models.Person", "person")
+ .WithMany()
+ .HasForeignKey("personId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126121407_ForeignKeys.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126121407_ForeignKeys.cs
new file mode 100644
index 0000000..c9ecac1
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126121407_ForeignKeys.cs
@@ -0,0 +1,60 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace MyTimesheet.Migrations
+{
+ public partial class ForeignKeys : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Entries_Date_dateId",
+ table: "Entries");
+
+ migrationBuilder.AlterColumn(
+ name: "dateId",
+ table: "Entries",
+ nullable: false,
+ oldClrType: typeof(int),
+ oldNullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "clientIid",
+ table: "Entries",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Entries_Date_dateId",
+ table: "Entries",
+ column: "dateId",
+ principalTable: "Date",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Entries_Date_dateId",
+ table: "Entries");
+
+ migrationBuilder.DropColumn(
+ name: "clientIid",
+ table: "Entries");
+
+ migrationBuilder.AlterColumn(
+ name: "dateId",
+ table: "Entries",
+ nullable: true,
+ oldClrType: typeof(int));
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Entries_Date_dateId",
+ table: "Entries",
+ column: "dateId",
+ principalTable: "Date",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs b/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs
new file mode 100644
index 0000000..b55db0a
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs
@@ -0,0 +1,125 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyTimesheet.Models;
+
+namespace MyTimesheet.Migrations
+{
+ [DbContext(typeof(TimesheetContext))]
+ partial class TimesheetContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("MyTimesheet.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Project")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.Property("client")
+ .IsRequired()
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Client");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Date", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Duration");
+
+ b.Property("TimeEnd");
+
+ b.Property("TimeStart");
+
+ b.Property("date");
+
+ b.HasKey("Id");
+
+ b.ToTable("Date");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Name")
+ .HasMaxLength(30);
+
+ b.Property("Surname")
+ .HasMaxLength(30);
+
+ b.HasKey("Id");
+
+ b.ToTable("Person");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Billable");
+
+ b.Property("Description");
+
+ b.Property("clientId");
+
+ b.Property("clientIid");
+
+ b.Property("dateId");
+
+ b.Property("personId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("clientId");
+
+ b.HasIndex("dateId");
+
+ b.HasIndex("personId");
+
+ b.ToTable("Entries");
+ });
+
+ modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b =>
+ {
+ b.HasOne("MyTimesheet.Models.Client", "client")
+ .WithMany()
+ .HasForeignKey("clientId");
+
+ b.HasOne("MyTimesheet.Models.Date", "date")
+ .WithMany()
+ .HasForeignKey("dateId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("MyTimesheet.Models.Person", "person")
+ .WithMany()
+ .HasForeignKey("personId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Models/Client.cs b/src/MyTimesheet/MyTimesheet/Models/Client.cs
new file mode 100644
index 0000000..ebf53ab
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Models/Client.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MyTimesheet.Models
+{
+ public class Client
+ {
+ [Key]
+ public int Id { get; set; }
+ [MaxLength(30)]
+ [Required]
+ public string client { get; set; }
+ [MaxLength(30)]
+ [Required]
+ public string Project { get; set; }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Models/Date.cs b/src/MyTimesheet/MyTimesheet/Models/Date.cs
new file mode 100644
index 0000000..de8805b
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Models/Date.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MyTimesheet.Models
+{
+ public class Date
+ {
+ [Key]
+ public int Id { get; set; }
+ public DateTime date { get; set; }
+ public DateTime TimeStart { get; set; }
+ public DateTime TimeEnd { get; set; }
+ public int Duration { get; set; }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Models/Person.cs b/src/MyTimesheet/MyTimesheet/Models/Person.cs
new file mode 100644
index 0000000..df64986
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Models/Person.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MyTimesheet.Models
+{
+ public class Person
+ {
+ [Key]
+ public int Id { get; set; }
+ [MaxLength(30)]
+ public string Name { get; set; }
+ [MaxLength(30)]
+ public string Surname { get; set; }
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Models/TimesheetContext.cs b/src/MyTimesheet/MyTimesheet/Models/TimesheetContext.cs
index 5bf7e22..3d396cc 100644
--- a/src/MyTimesheet/MyTimesheet/Models/TimesheetContext.cs
+++ b/src/MyTimesheet/MyTimesheet/Models/TimesheetContext.cs
@@ -13,6 +13,8 @@ public TimesheetContext(DbContextOptions options)
{ }
public DbSet Entries { get; set; }
-
+ public DbSet Date { get; set; }
+ public DbSet Person { get; set; }
+ public DbSet Client { get; set; }
}
}
diff --git a/src/MyTimesheet/MyTimesheet/Models/TimesheetEntry.cs b/src/MyTimesheet/MyTimesheet/Models/TimesheetEntry.cs
index 8c65667..40ab898 100644
--- a/src/MyTimesheet/MyTimesheet/Models/TimesheetEntry.cs
+++ b/src/MyTimesheet/MyTimesheet/Models/TimesheetEntry.cs
@@ -15,14 +15,12 @@ public class TimesheetEntry
*/
public int Id { get; set; }
- public string Name { get; set; }
- public string Surname { get; set; }
- public string Client { get; set; }
- public string Project { get; set; }
- public DateTime Date { get; set; }
- public DateTime TimeStart { get; set; }
- public DateTime TimeEnd { get; set; }
- public int Duration { get; set; }
+ public int personId { get; set; }
+ public int dateId { get; set; }
+ public int clientIid { get; set; }
+ public Person person { get; set; }
+ public Client client { get; set; }
+ public Date date { get; set; }
public string Description { get; set; }
public bool Billable { get; set; }
}
diff --git a/src/MyTimesheet/MyTimesheet/Providers/RedisProvider.cs b/src/MyTimesheet/MyTimesheet/Providers/RedisProvider.cs
new file mode 100644
index 0000000..200b139
--- /dev/null
+++ b/src/MyTimesheet/MyTimesheet/Providers/RedisProvider.cs
@@ -0,0 +1,46 @@
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+using MyTimesheet.Interfaces;
+using StackExchange.Redis;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MyTimesheet.Providers
+{
+ public class RedisProvider : RediProviderInterface
+ {
+ private readonly ILogger _logger;
+ private readonly IConfiguration _config;
+ private IDatabase cache;
+
+ public RedisProvider(ILogger logger, IConfiguration config)
+ {
+ _logger = logger;
+ _config = config;
+ var cacheConnection = _config.GetValue("CacheConnection").ToString();
+ var lazyConnection = new Lazy(() =>
+ {
+ return ConnectionMultiplexer.Connect(cacheConnection);
+ });
+
+ cache = lazyConnection.Value.GetDatabase();
+ }
+ public async Task SaveAsync(string key, object obj)
+ {
+
+ await cache.StringSetAsync(key, obj.ToString());
+
+ var cacheItem = await cache.StringGetAsync(key);
+ if (cacheItem.ToString().Length > 0)
+ return true;
+ else return false;
+ }
+ public async Task GetAsync(string Key)
+ {
+ return await cache.StringGetAsync(Key);
+ }
+
+ }
+}
diff --git a/src/MyTimesheet/MyTimesheet/Startup.cs b/src/MyTimesheet/MyTimesheet/Startup.cs
index e81072d..2c9cf11 100644
--- a/src/MyTimesheet/MyTimesheet/Startup.cs
+++ b/src/MyTimesheet/MyTimesheet/Startup.cs
@@ -10,7 +10,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
+using MyTimesheet.Interfaces;
using MyTimesheet.Models;
+using MyTimesheet.Providers;
using Swashbuckle.AspNetCore.Swagger;
namespace MyTimesheet
@@ -35,9 +37,11 @@ public void ConfigureServices(IServiceCollection services)
c.SwaggerDoc("v1", new Info { Title = "My Timesheet API", Version = "v1" });
});
- var connection = @"Server=sql101labs1793591179000.westeurope.cloudapp.azure.com;Database=sql101.#NAME.SURNAME;User Id=myUsername;Password=myPassword;";
+ var connection = @"Server=sql101labs1793591179000.westeurope.cloudapp.azure.com;Database=sql101.ilze.lourens;User Id=ilzelourens;Password=19970219aB@;";
services.AddDbContext
(options => options.UseSqlServer(connection));
+ services.AddScoped();
+ services.AddSingleton(Configuration);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
diff --git a/src/MyTimesheet/MyTimesheet/appsettings.json b/src/MyTimesheet/MyTimesheet/appsettings.json
index def9159..42317b9 100644
--- a/src/MyTimesheet/MyTimesheet/appsettings.json
+++ b/src/MyTimesheet/MyTimesheet/appsettings.json
@@ -4,5 +4,8 @@
"Default": "Warning"
}
},
- "AllowedHosts": "*"
+ "AllowedHosts": "*",
+ "CacheConnection": "101.redis.cache.windows.net,abortConnect=false,ssl=true,password=85BYRVqUHV6aW7Jz8zIIxRnaYMgbBd2kwo4bpDiz4vw="
}
+//".redis.cache.windows.net,abortConnect=false,ssl=true,password="
+