From aecacd4dacc6c16a81b3f8b2ef89cf2819d707ef Mon Sep 17 00:00:00 2001 From: Bartosz Chyzy Date: Sun, 2 Dec 2018 00:19:58 +0100 Subject: [PATCH] Dodano seedy bazy danych --- .../ContextProviders/ApplicationDbContext.cs | 2 +- .../Forum.DataAccessLayer.csproj | 7 + .../201812012312365_Seedtry.Designer.cs | 29 ++++ .../Migrations/201812012312365_Seedtry.cs | 16 +++ .../Migrations/201812012312365_Seedtry.resx | 126 ++++++++++++++++++ .../Migrations/Configuration.cs | 27 +++- .../Forum/Forum/Views/Home/Category.cshtml | 9 ++ 7 files changed, 212 insertions(+), 4 deletions(-) create mode 100644 Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.Designer.cs create mode 100644 Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.cs create mode 100644 Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.resx diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/ContextProviders/ApplicationDbContext.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/ContextProviders/ApplicationDbContext.cs index 5568a85..afe79fd 100644 --- a/Trunk/Server/Forum/Forum.DataAccessLayer/ContextProviders/ApplicationDbContext.cs +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/ContextProviders/ApplicationDbContext.cs @@ -13,7 +13,7 @@ namespace Forum.DataAccessLayer { public ApplicationDbContext() : base("DefaultConnection", throwIfV1Schema: false) - { + { } public static ApplicationDbContext Create() diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Forum.DataAccessLayer.csproj b/Trunk/Server/Forum/Forum.DataAccessLayer/Forum.DataAccessLayer.csproj index d92921e..1fc4cf4 100644 --- a/Trunk/Server/Forum/Forum.DataAccessLayer/Forum.DataAccessLayer.csproj +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Forum.DataAccessLayer.csproj @@ -94,6 +94,10 @@ 201812012216378_Added Title.cs + + + 201812012312365_Seedtry.cs + @@ -125,6 +129,9 @@ 201812012216378_Added Title.cs + + 201812012312365_Seedtry.cs + diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.Designer.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.Designer.cs new file mode 100644 index 0000000..d7ed043 --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.Designer.cs @@ -0,0 +1,29 @@ +// +namespace Forum.DataAccessLayer.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")] + public sealed partial class Seedtry : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(Seedtry)); + + string IMigrationMetadata.Id + { + get { return "201812012312365_Seedtry"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.cs new file mode 100644 index 0000000..eabc681 --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.cs @@ -0,0 +1,16 @@ +namespace Forum.DataAccessLayer.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class Seedtry : DbMigration + { + public override void Up() + { + } + + public override void Down() + { + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.resx b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.resx new file mode 100644 index 0000000..c53eebf --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012312365_Seedtry.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1d227kuBF9D5B/EPSUBN5uXzKDidG9C2/b3hgZXzLtWeTNoCW6LYwuvRI1YyPYL8tDPim/EFJXXiVSUqvlTTAvbZE8LBariqwiWfOff/178cNL4FtfYZx4Ubi0j2aHtgVDJ3K9cLO0U/T03Qf7h+9//7vFhRu8WD+X9U5IPdwyTJb2M0Lb0/k8cZ5hAJJZ4DlxlERPaOZEwRy40fz48PAv86OjOcQQNsayrMWnNEReALM/8J+rKHTgFqXAv45c6CfFd1yyzlCtGxDAZAscuLQvozgNZucAgTPHgUnyEbzC2LbOfA9gYtbQf7ItEIYRAgiTevo5gWsUR+FmvcUfgH//uoW43hPwE1gM4bSurjuaw2MymnndsIRy0gRFgSHg0UnBnjnfvBOT7Yp9mIEXmNHolYw6Y+LSPguTb4RhfFenKz8m1RQcnuUzM8ubH1hNlQ4qQcHyRP4dWKvUR2kMlyFMUQz8A+suffQ952/w9T76AsNlmPo+TTemHJcxH/Cnuzjawhi9foJPxWiuXNuas+3mfMOqGdUmH+lViE6ObesGdw4efViJBcWVNYpi+BMMYQwQdO8AQjAOCQbMGCv0zvWFGQTL3sjveyz1kg6bQbB6INxdiYPlGWunbV2Dl48w3KDnpY1/2tal9wLd8ksB/Dn0sDLjRihOW/u58Zwvw3dyA756m4yZXHf4zycsObgA+Lb1CfpZpeTZ2+Z6XMjaA1vvMo6CT5FfSTJT/LCO0tghHI/Ude5BvIFIn86/pzDJlVFCY1n4kPeU0ATyZVXPJXVChZJ8mrTFvNbhRs2mB4nNXncd54F+I9ouEemj4w9aIm2osJe4Ovm1c429CIDnN/Ry/O79UL1gI/TkxQGs2Pljh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FgsBrjcpJXEerUcxPP+DUMYxhtVzxW3QFjdpfgaxi20Mokf6fZnyk7Seg1HDvYFZZ+rtB/6DtK3iXNKbW3Qe4wNZcsE5fsSktHFk0v65ZUF2V6OIpGG2TZEh8G4K1zGpLz+fyvc5h4mxqCPGcJocNsmqs6V+FTVO7dOYrKKtxp4DVEwCVvT2LkPQEH4WJyXTH7/1SyK2Dk0uwjdK/C2xRtU4SHDINHn5El4gM09Z+lEmNpXtxuM1EeYgiYTI9cabgNf0w9363ovpScOyogiHNRnEiTuUTkZHrzWiHdRKEmUMG+yie6h8HWx2DJbbgGX2EX2rD4fYQb4LzW98VUIO0TwbJ9ce6BTQyCpMCo2+M/sQy7wcv3/wVowLfeJYcAAA== + + + dbo + + \ No newline at end of file diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/Configuration.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/Configuration.cs index 68fb04a..4df9fcb 100644 --- a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/Configuration.cs +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/Configuration.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using Forum.DataAccessLayer.Models; + namespace Forum.DataAccessLayer.Migrations { using System; @@ -14,10 +17,28 @@ namespace Forum.DataAccessLayer.Migrations protected override void Seed(Forum.DataAccessLayer.ApplicationDbContext context) { - // This method will be called after migrating to the latest version. + if (!context.Categories.Any(c=>c.CategoryName=="Zwroty")) + { + var zwroty = new Category() + { + CategoryName = "Zwroty", + Questions = new List() + { + new Question() + { + Title = "Jak dokonaæ zwrotu", + Content = "Chce dostaæ zwrot nwm co robic pls admian halp!11", + IsClosed = false, + PostDate = DateTime.Now, + Nick = "Potrzebuj¹cy" + } + } + }; - // You can use the DbSet.AddOrUpdate() helper extension method - // to avoid creating duplicate seed data. + context.Categories.Add(zwroty); + + context.SaveChanges(); + } } } } diff --git a/Trunk/Server/Forum/Forum/Views/Home/Category.cshtml b/Trunk/Server/Forum/Forum/Views/Home/Category.cshtml index b0703d6..e7de7c0 100644 --- a/Trunk/Server/Forum/Forum/Views/Home/Category.cshtml +++ b/Trunk/Server/Forum/Forum/Views/Home/Category.cshtml @@ -5,3 +5,12 @@ }

@Model.CategoryName

+ +
    + @{ + foreach (var question in Model.Questions) + { +
  • @Html.ActionLink(question.Title,"Question","Home",new{id=question.Id},null)
  • + } + } +