From cedede35e7774606fd0019682ef1b414fd9897df Mon Sep 17 00:00:00 2001 From: mthembbu Date: Tue, 22 Jan 2019 14:33:35 +0200 Subject: [PATCH 1/2] an updated createuser.sql and createdatabase.sql script from the persistance sql workshop --- data/createdatabase.sql | 76 +++++++++---------- data/createuser.sql | 14 ++-- ...0190122091737_InitialMigration.Designer.cs | 57 ++++++++++++++ .../20190122091737_InitialMigration.cs | 42 ++++++++++ .../TimesheetContextModelSnapshot.cs | 55 ++++++++++++++ src/MyTimesheet/MyTimesheet/Startup.cs | 2 +- 6 files changed, 200 insertions(+), 46 deletions(-) create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190122091737_InitialMigration.Designer.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190122091737_InitialMigration.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs diff --git a/data/createdatabase.sql b/data/createdatabase.sql index 41b5a17..bdf3658 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.buhle.mthembu] Script Date: 1/21/2019 9:11:50 PM ******/ +CREATE DATABASE [sql101.buhle.mthembu] 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.buhle.mthembu', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\sql101.buhle.mthembu.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.buhle.mthembu', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\sql101.buhle.mthembu_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB ) GO -ALTER DATABASE [sql101.firstname.lastname] SET COMPATIBILITY_LEVEL = 130 +ALTER DATABASE [sql101.buhle.mthembu] SET COMPATIBILITY_LEVEL = 130 GO IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')) begin -EXEC [sql101.firstname.lastname].[dbo].[sp_fulltext_database] @action = 'enable' +EXEC [sql101.buhle.mthembu].[dbo].[sp_fulltext_database] @action = 'enable' end GO -ALTER DATABASE [sql101.firstname.lastname] SET ANSI_NULL_DEFAULT OFF +ALTER DATABASE [sql101.buhle.mthembu] SET ANSI_NULL_DEFAULT OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET ANSI_NULLS OFF +ALTER DATABASE [sql101.buhle.mthembu] SET ANSI_NULLS OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET ANSI_PADDING OFF +ALTER DATABASE [sql101.buhle.mthembu] SET ANSI_PADDING OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET ANSI_WARNINGS OFF +ALTER DATABASE [sql101.buhle.mthembu] SET ANSI_WARNINGS OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET ARITHABORT OFF +ALTER DATABASE [sql101.buhle.mthembu] SET ARITHABORT OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET AUTO_CLOSE OFF +ALTER DATABASE [sql101.buhle.mthembu] SET AUTO_CLOSE OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET AUTO_SHRINK OFF +ALTER DATABASE [sql101.buhle.mthembu] SET AUTO_SHRINK OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET AUTO_UPDATE_STATISTICS ON +ALTER DATABASE [sql101.buhle.mthembu] SET AUTO_UPDATE_STATISTICS ON GO -ALTER DATABASE [sql101.firstname.lastname] SET CURSOR_CLOSE_ON_COMMIT OFF +ALTER DATABASE [sql101.buhle.mthembu] SET CURSOR_CLOSE_ON_COMMIT OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET CURSOR_DEFAULT GLOBAL +ALTER DATABASE [sql101.buhle.mthembu] SET CURSOR_DEFAULT GLOBAL GO -ALTER DATABASE [sql101.firstname.lastname] SET CONCAT_NULL_YIELDS_NULL OFF +ALTER DATABASE [sql101.buhle.mthembu] SET CONCAT_NULL_YIELDS_NULL OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET NUMERIC_ROUNDABORT OFF +ALTER DATABASE [sql101.buhle.mthembu] SET NUMERIC_ROUNDABORT OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET QUOTED_IDENTIFIER OFF +ALTER DATABASE [sql101.buhle.mthembu] SET QUOTED_IDENTIFIER OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET RECURSIVE_TRIGGERS OFF +ALTER DATABASE [sql101.buhle.mthembu] SET RECURSIVE_TRIGGERS OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET DISABLE_BROKER +ALTER DATABASE [sql101.buhle.mthembu] SET DISABLE_BROKER GO -ALTER DATABASE [sql101.firstname.lastname] SET AUTO_UPDATE_STATISTICS_ASYNC OFF +ALTER DATABASE [sql101.buhle.mthembu] SET AUTO_UPDATE_STATISTICS_ASYNC OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET DATE_CORRELATION_OPTIMIZATION OFF +ALTER DATABASE [sql101.buhle.mthembu] SET DATE_CORRELATION_OPTIMIZATION OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET TRUSTWORTHY OFF +ALTER DATABASE [sql101.buhle.mthembu] SET TRUSTWORTHY OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET ALLOW_SNAPSHOT_ISOLATION OFF +ALTER DATABASE [sql101.buhle.mthembu] SET ALLOW_SNAPSHOT_ISOLATION OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET PARAMETERIZATION SIMPLE +ALTER DATABASE [sql101.buhle.mthembu] SET PARAMETERIZATION SIMPLE GO -ALTER DATABASE [sql101.firstname.lastname] SET READ_COMMITTED_SNAPSHOT OFF +ALTER DATABASE [sql101.buhle.mthembu] SET READ_COMMITTED_SNAPSHOT OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET HONOR_BROKER_PRIORITY OFF +ALTER DATABASE [sql101.buhle.mthembu] SET HONOR_BROKER_PRIORITY OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET RECOVERY FULL +ALTER DATABASE [sql101.buhle.mthembu] SET RECOVERY FULL GO -ALTER DATABASE [sql101.firstname.lastname] SET MULTI_USER +ALTER DATABASE [sql101.buhle.mthembu] SET MULTI_USER GO -ALTER DATABASE [sql101.firstname.lastname] SET PAGE_VERIFY CHECKSUM +ALTER DATABASE [sql101.buhle.mthembu] SET PAGE_VERIFY CHECKSUM GO -ALTER DATABASE [sql101.firstname.lastname] SET DB_CHAINING OFF +ALTER DATABASE [sql101.buhle.mthembu] SET DB_CHAINING OFF GO -ALTER DATABASE [sql101.firstname.lastname] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) +ALTER DATABASE [sql101.buhle.mthembu] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) GO -ALTER DATABASE [sql101.firstname.lastname] SET TARGET_RECOVERY_TIME = 60 SECONDS +ALTER DATABASE [sql101.buhle.mthembu] SET TARGET_RECOVERY_TIME = 60 SECONDS GO -ALTER DATABASE [sql101.firstname.lastname] SET DELAYED_DURABILITY = DISABLED +ALTER DATABASE [sql101.buhle.mthembu] SET DELAYED_DURABILITY = DISABLED GO -ALTER DATABASE [sql101.firstname.lastname] SET QUERY_STORE = OFF +ALTER DATABASE [sql101.buhle.mthembu] SET QUERY_STORE = OFF GO -USE [sql101.firstname.lastname] +USE [sql101.buhle.mthembu] 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.buhle.mthembu] SET READ_WRITE GO diff --git a/data/createuser.sql b/data/createuser.sql index bcf3038..52fbc1c 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 -GO -use [sql101.firstname.lastname] +CREATE LOGIN [scott] WITH PASSWORD=N'rabbit123!@# MUST_CHANGE, DEFAULT_DATABASE=[sql101.buhle.mthembu], CHECK_EXPIRATION=ON, CHECK_POLICY=ON + +use [sql101.buhle.mthembu] GO use [master] GO -USE [sql101.firstname.lastname] +USE [sql101.buhle.mthembu] GO -CREATE USER [firstnamelastname] FOR LOGIN [firstnamelastname] +CREATE USER [zeenhle] FOR LOGIN [scott] GO -USE [sql101.firstname.lastname] +USE [sql101.buhle.mthembu] GO -ALTER ROLE [db_owner] ADD MEMBER [firstnamelastname] +ALTER ROLE [scott] ADD MEMBER [zeenhle] GO diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190122091737_InitialMigration.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190122091737_InitialMigration.Designer.cs new file mode 100644 index 0000000..38cb487 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190122091737_InitialMigration.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("20190122091737_InitialMigration")] + partial class InitialMigration + { + 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/20190122091737_InitialMigration.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190122091737_InitialMigration.cs new file mode 100644 index 0000000..bc5fb6d --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190122091737_InitialMigration.cs @@ -0,0 +1,42 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace MyTimesheet.Migrations +{ + public partial class InitialMigration : 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/TimesheetContextModelSnapshot.cs b/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs new file mode 100644 index 0000000..6404921 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs @@ -0,0 +1,55 @@ +// +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.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/Startup.cs b/src/MyTimesheet/MyTimesheet/Startup.cs index e81072d..b54345d 100644 --- a/src/MyTimesheet/MyTimesheet/Startup.cs +++ b/src/MyTimesheet/MyTimesheet/Startup.cs @@ -35,7 +35,7 @@ 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.buhle.mthembu;User Id=bmthembu;Password=#mthembu.$2015;"; services.AddDbContext (options => options.UseSqlServer(connection)); } From f74f2be0734d6867f3c498daa7a011e724565d27 Mon Sep 17 00:00:00 2001 From: mthembbu Date: Sat, 26 Jan 2019 18:34:52 +0200 Subject: [PATCH 2/2] Added both a new Project Object, and was able to create a new Migration that can add both tables, and data can be queried for both Projects and Entries... --- .../Controllers/TimesheetController.cs | 24 ++- .../20190126093359_InitialCreate.Designer.cs | 57 +++++++ .../20190126093359_InitialCreate.cs | 17 ++ ...190126115123_InintiaMigraition.Designer.cs | 79 ++++++++++ .../20190126115123_InintiaMigraition.cs | 145 ++++++++++++++++++ .../20190126140140_EmpReview.Designer.cs | 131 ++++++++++++++++ .../Migrations/20190126140140_EmpReview.cs | 116 ++++++++++++++ .../20190126142159_EmpReview2.Designer.cs | 83 ++++++++++ .../Migrations/20190126142159_EmpReview2.cs | 96 ++++++++++++ .../TimesheetContextModelSnapshot.cs | 39 ++++- .../MyTimesheet/Models/Employee.cs | 20 +++ src/MyTimesheet/MyTimesheet/Models/Project.cs | 21 +++ .../MyTimesheet/Models/TimesheetContext.cs | 2 + .../MyTimesheet/Models/TimesheetEntry.cs | 24 ++- .../MyTimesheet/MyTimesheet.csproj | 1 + src/MyTimesheet/MyTimesheet/Startup.cs | 1 + src/MyTimesheet/MyTimesheet/appsettings.json | 4 +- .../MyTimesheet/cacheSecrets.config | 5 + 18 files changed, 848 insertions(+), 17 deletions(-) create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190126093359_InitialCreate.Designer.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190126093359_InitialCreate.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190126115123_InintiaMigraition.Designer.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190126115123_InintiaMigraition.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190126140140_EmpReview.Designer.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190126140140_EmpReview.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190126142159_EmpReview2.Designer.cs create mode 100644 src/MyTimesheet/MyTimesheet/Migrations/20190126142159_EmpReview2.cs create mode 100644 src/MyTimesheet/MyTimesheet/Models/Employee.cs create mode 100644 src/MyTimesheet/MyTimesheet/Models/Project.cs create mode 100644 src/MyTimesheet/MyTimesheet/cacheSecrets.config diff --git a/src/MyTimesheet/MyTimesheet/Controllers/TimesheetController.cs b/src/MyTimesheet/MyTimesheet/Controllers/TimesheetController.cs index b2f5a7c..0816738 100644 --- a/src/MyTimesheet/MyTimesheet/Controllers/TimesheetController.cs +++ b/src/MyTimesheet/MyTimesheet/Controllers/TimesheetController.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using MyTimesheet.Models; +using StackExchange.Redis; using System; using System.Collections.Generic; using System.Linq; @@ -13,9 +15,11 @@ namespace MyTimesheet.Controllers public class TimesheetController : ControllerBase { private readonly TimesheetContext _db; - public TimesheetController(TimesheetContext context) + readonly IConfiguration _iconfig; + public TimesheetController(TimesheetContext context, IConfiguration config) { _db = context; + _iconfig = config; } // GET api/values @@ -34,10 +38,26 @@ public async Task> Get(int id) // 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 cacheConnection = _iconfig.GetValue("CacheConnection"); + var lazyConnection = new Lazy(() => + { + return ConnectionMultiplexer.Connect(cacheConnection); + }); + IDatabase cache = lazyConnection.Value.GetDatabase(); + await cache.SetAddAsync($"{ value.Name} +{value.Surname}", value.ToString()); + + var cacheItem = await cache.StringGetAsync($"{value.Name}+{value.Surname}"); + + // + lazyConnection.Value.Dispose(); + + return cacheItem; } // PUT api/values/5 diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126093359_InitialCreate.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126093359_InitialCreate.Designer.cs new file mode 100644 index 0000000..43873ad --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126093359_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("20190126093359_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/20190126093359_InitialCreate.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126093359_InitialCreate.cs new file mode 100644 index 0000000..f6808c6 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126093359_InitialCreate.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace MyTimesheet.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126115123_InintiaMigraition.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126115123_InintiaMigraition.Designer.cs new file mode 100644 index 0000000..0964dab --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126115123_InintiaMigraition.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("20190126115123_InintiaMigraition")] + partial class InintiaMigraition + { + 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.Project", 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("ProjectName"); + + b.Property("TimeEnd"); + + b.Property("TimeStart"); + + b.HasKey("Id"); + + b.ToTable("Projects"); + }); + + modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Name"); + + b.Property("ProjectsId"); + + b.Property("Surname"); + + b.HasKey("Id"); + + b.HasIndex("ProjectsId"); + + b.ToTable("Entries"); + }); + + modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + { + b.HasOne("MyTimesheet.Models.Project", "Projects") + .WithMany() + .HasForeignKey("ProjectsId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126115123_InintiaMigraition.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126115123_InintiaMigraition.cs new file mode 100644 index 0000000..14c8269 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126115123_InintiaMigraition.cs @@ -0,0 +1,145 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace MyTimesheet.Migrations +{ + public partial class InintiaMigraition : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Billable", + table: "Entries"); + + migrationBuilder.DropColumn( + name: "Client", + table: "Entries"); + + migrationBuilder.DropColumn( + name: "Date", + table: "Entries"); + + migrationBuilder.DropColumn( + name: "Description", + table: "Entries"); + + migrationBuilder.DropColumn( + name: "Duration", + table: "Entries"); + + migrationBuilder.DropColumn( + name: "Project", + table: "Entries"); + + migrationBuilder.DropColumn( + name: "TimeEnd", + table: "Entries"); + + migrationBuilder.DropColumn( + name: "TimeStart", + table: "Entries"); + + migrationBuilder.AddColumn( + name: "ProjectsId", + table: "Entries", + nullable: true); + + migrationBuilder.CreateTable( + name: "Projects", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + Client = table.Column(nullable: true), + ProjectName = 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_Projects", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Entries_ProjectsId", + table: "Entries", + column: "ProjectsId"); + + migrationBuilder.AddForeignKey( + name: "FK_Entries_Projects_ProjectsId", + table: "Entries", + column: "ProjectsId", + principalTable: "Projects", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Entries_Projects_ProjectsId", + table: "Entries"); + + migrationBuilder.DropTable( + name: "Projects"); + + migrationBuilder.DropIndex( + name: "IX_Entries_ProjectsId", + table: "Entries"); + + migrationBuilder.DropColumn( + name: "ProjectsId", + table: "Entries"); + + migrationBuilder.AddColumn( + name: "Billable", + table: "Entries", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "Client", + table: "Entries", + nullable: true); + + migrationBuilder.AddColumn( + name: "Date", + table: "Entries", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "Description", + table: "Entries", + nullable: true); + + migrationBuilder.AddColumn( + name: "Duration", + table: "Entries", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "Project", + table: "Entries", + nullable: true); + + 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/20190126140140_EmpReview.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126140140_EmpReview.Designer.cs new file mode 100644 index 0000000..272a6e7 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126140140_EmpReview.Designer.cs @@ -0,0 +1,131 @@ +// +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("20190126140140_EmpReview")] + partial class EmpReview + { + 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.Employee", b => + { + b.Property("EmpId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("JobTitle"); + + b.Property("Name"); + + b.Property("Surname"); + + b.Property("Team"); + + b.Property("TimesheetEntryId"); + + b.HasKey("EmpId"); + + b.HasIndex("TimesheetEntryId"); + + b.ToTable("Employee"); + }); + + modelBuilder.Entity("MyTimesheet.Models.Project", 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("EmpID"); + + b.Property("ProjectName"); + + b.Property("TimeEnd"); + + b.Property("TimeStart"); + + b.Property("TimesheetEntryId"); + + b.HasKey("Id"); + + b.HasIndex("EmpID"); + + b.HasIndex("TimesheetEntryId"); + + b.ToTable("Projects"); + }); + + modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("EmpId"); + + b.Property("Name"); + + b.Property("ProjectsId"); + + b.Property("Surname"); + + b.HasKey("Id"); + + b.HasIndex("ProjectsId"); + + b.ToTable("Entries"); + }); + + modelBuilder.Entity("MyTimesheet.Models.Employee", b => + { + b.HasOne("MyTimesheet.Models.TimesheetEntry") + .WithMany("EmployeeList") + .HasForeignKey("TimesheetEntryId"); + }); + + modelBuilder.Entity("MyTimesheet.Models.Project", b => + { + b.HasOne("MyTimesheet.Models.Employee") + .WithMany("getProjects") + .HasForeignKey("EmpID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("MyTimesheet.Models.TimesheetEntry") + .WithMany("ProjectList") + .HasForeignKey("TimesheetEntryId"); + }); + + modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + { + b.HasOne("MyTimesheet.Models.Project", "Projects") + .WithMany() + .HasForeignKey("ProjectsId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126140140_EmpReview.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126140140_EmpReview.cs new file mode 100644 index 0000000..962d64d --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126140140_EmpReview.cs @@ -0,0 +1,116 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace MyTimesheet.Migrations +{ + public partial class EmpReview : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "EmpID", + table: "Projects", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TimesheetEntryId", + table: "Projects", + nullable: true); + + migrationBuilder.AddColumn( + name: "EmpId", + table: "Entries", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "Employee", + columns: table => new + { + EmpId = table.Column(nullable: false) + .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + Name = table.Column(nullable: true), + Surname = table.Column(nullable: true), + JobTitle = table.Column(nullable: true), + Team = table.Column(nullable: true), + TimesheetEntryId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Employee", x => x.EmpId); + table.ForeignKey( + name: "FK_Employee_Entries_TimesheetEntryId", + column: x => x.TimesheetEntryId, + principalTable: "Entries", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_Projects_EmpID", + table: "Projects", + column: "EmpID"); + + migrationBuilder.CreateIndex( + name: "IX_Projects_TimesheetEntryId", + table: "Projects", + column: "TimesheetEntryId"); + + migrationBuilder.CreateIndex( + name: "IX_Employee_TimesheetEntryId", + table: "Employee", + column: "TimesheetEntryId"); + + migrationBuilder.AddForeignKey( + name: "FK_Projects_Employee_EmpID", + table: "Projects", + column: "EmpID", + principalTable: "Employee", + principalColumn: "EmpId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Projects_Entries_TimesheetEntryId", + table: "Projects", + column: "TimesheetEntryId", + principalTable: "Entries", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Projects_Employee_EmpID", + table: "Projects"); + + migrationBuilder.DropForeignKey( + name: "FK_Projects_Entries_TimesheetEntryId", + table: "Projects"); + + migrationBuilder.DropTable( + name: "Employee"); + + migrationBuilder.DropIndex( + name: "IX_Projects_EmpID", + table: "Projects"); + + migrationBuilder.DropIndex( + name: "IX_Projects_TimesheetEntryId", + table: "Projects"); + + migrationBuilder.DropColumn( + name: "EmpID", + table: "Projects"); + + migrationBuilder.DropColumn( + name: "TimesheetEntryId", + table: "Projects"); + + migrationBuilder.DropColumn( + name: "EmpId", + table: "Entries"); + } + } +} diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126142159_EmpReview2.Designer.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126142159_EmpReview2.Designer.cs new file mode 100644 index 0000000..b1f385a --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126142159_EmpReview2.Designer.cs @@ -0,0 +1,83 @@ +// +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("20190126142159_EmpReview2")] + partial class EmpReview2 + { + 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.Project", 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("EmpID"); + + b.Property("ProjectName"); + + b.Property("TimeEnd"); + + b.Property("TimeStart"); + + b.HasKey("Id"); + + b.ToTable("Projects"); + }); + + modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("EmpId"); + + b.Property("Name"); + + b.Property("ProjectsId"); + + b.Property("Surname"); + + b.HasKey("Id"); + + b.HasIndex("ProjectsId"); + + b.ToTable("Entries"); + }); + + modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + { + b.HasOne("MyTimesheet.Models.Project", "Projects") + .WithMany() + .HasForeignKey("ProjectsId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MyTimesheet/MyTimesheet/Migrations/20190126142159_EmpReview2.cs b/src/MyTimesheet/MyTimesheet/Migrations/20190126142159_EmpReview2.cs new file mode 100644 index 0000000..2dac915 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Migrations/20190126142159_EmpReview2.cs @@ -0,0 +1,96 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace MyTimesheet.Migrations +{ + public partial class EmpReview2 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Projects_Employee_EmpID", + table: "Projects"); + + migrationBuilder.DropForeignKey( + name: "FK_Projects_Entries_TimesheetEntryId", + table: "Projects"); + + migrationBuilder.DropTable( + name: "Employee"); + + migrationBuilder.DropIndex( + name: "IX_Projects_EmpID", + table: "Projects"); + + migrationBuilder.DropIndex( + name: "IX_Projects_TimesheetEntryId", + table: "Projects"); + + migrationBuilder.DropColumn( + name: "TimesheetEntryId", + table: "Projects"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TimesheetEntryId", + table: "Projects", + nullable: true); + + migrationBuilder.CreateTable( + name: "Employee", + columns: table => new + { + EmpId = table.Column(nullable: false) + .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + JobTitle = table.Column(nullable: true), + Name = table.Column(nullable: true), + Surname = table.Column(nullable: true), + Team = table.Column(nullable: true), + TimesheetEntryId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Employee", x => x.EmpId); + table.ForeignKey( + name: "FK_Employee_Entries_TimesheetEntryId", + column: x => x.TimesheetEntryId, + principalTable: "Entries", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_Projects_EmpID", + table: "Projects", + column: "EmpID"); + + migrationBuilder.CreateIndex( + name: "IX_Projects_TimesheetEntryId", + table: "Projects", + column: "TimesheetEntryId"); + + migrationBuilder.CreateIndex( + name: "IX_Employee_TimesheetEntryId", + table: "Employee", + column: "TimesheetEntryId"); + + migrationBuilder.AddForeignKey( + name: "FK_Projects_Employee_EmpID", + table: "Projects", + column: "EmpID", + principalTable: "Employee", + principalColumn: "EmpId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Projects_Entries_TimesheetEntryId", + table: "Projects", + column: "TimesheetEntryId", + principalTable: "Entries", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs b/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs index 6404921..73e81c0 100644 --- a/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs +++ b/src/MyTimesheet/MyTimesheet/Migrations/TimesheetContextModelSnapshot.cs @@ -1,4 +1,5 @@ -// + +// using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -19,7 +20,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + modelBuilder.Entity("MyTimesheet.Models.Project", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -35,11 +36,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Duration"); - b.Property("Name"); - - b.Property("Project"); + b.Property("EmpID"); - b.Property("Surname"); + b.Property("ProjectName"); b.Property("TimeEnd"); @@ -47,8 +46,36 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); + b.ToTable("Projects"); + }); + + modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("EmpId"); + + b.Property("Name"); + + b.Property("ProjectsId"); + + b.Property("Surname"); + + b.HasKey("Id"); + + b.HasIndex("ProjectsId"); + b.ToTable("Entries"); }); + + modelBuilder.Entity("MyTimesheet.Models.TimesheetEntry", b => + { + b.HasOne("MyTimesheet.Models.Project", "Projects") + .WithMany() + .HasForeignKey("ProjectsId"); + }); #pragma warning restore 612, 618 } } diff --git a/src/MyTimesheet/MyTimesheet/Models/Employee.cs b/src/MyTimesheet/MyTimesheet/Models/Employee.cs new file mode 100644 index 0000000..1eafac6 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Models/Employee.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 Employee + { + [Key] + public int EmpId { get; set; } + public string Name { get; set; } + public string Surname { get; set; } + public string JobTitle { get; set; } + public string Team { get; set; } + + public ICollection getProjects { set; get; } + } +} diff --git a/src/MyTimesheet/MyTimesheet/Models/Project.cs b/src/MyTimesheet/MyTimesheet/Models/Project.cs new file mode 100644 index 0000000..b9e5824 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/Models/Project.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MyTimesheet.Models +{ + public class Project + { + public int Id { get; set; } + public int EmpID { get; set; } + public string Client { get; set; } + public string ProjectName { get; set; } + public DateTime Date { get; set; } + public DateTime TimeStart { get; set; } + public DateTime TimeEnd { get; set; } + public int Duration { get; set; } + public string Description { get; set; } + public bool Billable { get; set; } + } +} diff --git a/src/MyTimesheet/MyTimesheet/Models/TimesheetContext.cs b/src/MyTimesheet/MyTimesheet/Models/TimesheetContext.cs index 5bf7e22..800c2cd 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 Projects { get; set; } + // public DbSet Employees { get; set; } } } diff --git a/src/MyTimesheet/MyTimesheet/Models/TimesheetEntry.cs b/src/MyTimesheet/MyTimesheet/Models/TimesheetEntry.cs index 8c65667..f9e9a9e 100644 --- a/src/MyTimesheet/MyTimesheet/Models/TimesheetEntry.cs +++ b/src/MyTimesheet/MyTimesheet/Models/TimesheetEntry.cs @@ -15,15 +15,23 @@ public class TimesheetEntry */ public int Id { get; set; } + public int EmpId { get; set; } + + //public Employee Emp { 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 string Description { get; set; } - public bool Billable { get; set; } + public Project Projects { set; get; } + // public ICollection ProjectList { set; get; } + // public ICollection EmployeeList { set; get; } + + /* 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 string Description { get; set; } + public bool Billable { get; set; } + */ } } diff --git a/src/MyTimesheet/MyTimesheet/MyTimesheet.csproj b/src/MyTimesheet/MyTimesheet/MyTimesheet.csproj index 54dfccf..293cacb 100644 --- a/src/MyTimesheet/MyTimesheet/MyTimesheet.csproj +++ b/src/MyTimesheet/MyTimesheet/MyTimesheet.csproj @@ -9,6 +9,7 @@ + diff --git a/src/MyTimesheet/MyTimesheet/Startup.cs b/src/MyTimesheet/MyTimesheet/Startup.cs index b54345d..44180e6 100644 --- a/src/MyTimesheet/MyTimesheet/Startup.cs +++ b/src/MyTimesheet/MyTimesheet/Startup.cs @@ -38,6 +38,7 @@ public void ConfigureServices(IServiceCollection services) var connection = @"Server=sql101labs1793591179000.westeurope.cloudapp.azure.com;Database=sql101.buhle.mthembu;User Id=bmthembu;Password=#mthembu.$2015;"; services.AddDbContext (options => options.UseSqlServer(connection)); + 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..c050dfb 100644 --- a/src/MyTimesheet/MyTimesheet/appsettings.json +++ b/src/MyTimesheet/MyTimesheet/appsettings.json @@ -4,5 +4,7 @@ "Default": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "CacheConnection": "101.redis.cache.windows.net,abortConnect=false,ssl=true,password=85BYRVqUHV6aW7Jz8zIIxRnaYMgbBd2kwo4bpDiz4vw=" + } diff --git a/src/MyTimesheet/MyTimesheet/cacheSecrets.config b/src/MyTimesheet/MyTimesheet/cacheSecrets.config new file mode 100644 index 0000000..46ac173 --- /dev/null +++ b/src/MyTimesheet/MyTimesheet/cacheSecrets.config @@ -0,0 +1,5 @@ + + + + \ No newline at end of file