diff --git a/.vs/FakePieShop/FileContentIndex/17e3f4f7-1534-48da-acbe-64b9e4b66fd1.vsidx b/.vs/FakePieShop/FileContentIndex/17e3f4f7-1534-48da-acbe-64b9e4b66fd1.vsidx new file mode 100644 index 0000000..8172151 Binary files /dev/null and b/.vs/FakePieShop/FileContentIndex/17e3f4f7-1534-48da-acbe-64b9e4b66fd1.vsidx differ diff --git a/.vs/FakePieShop/FileContentIndex/21032597-1656-4332-976a-bf2f16774bc2.vsidx b/.vs/FakePieShop/FileContentIndex/21032597-1656-4332-976a-bf2f16774bc2.vsidx new file mode 100644 index 0000000..2508043 Binary files /dev/null and b/.vs/FakePieShop/FileContentIndex/21032597-1656-4332-976a-bf2f16774bc2.vsidx differ diff --git a/.vs/FakePieShop/FileContentIndex/2654b6c8-37aa-4614-a644-aea2f7465978.vsidx b/.vs/FakePieShop/FileContentIndex/2654b6c8-37aa-4614-a644-aea2f7465978.vsidx new file mode 100644 index 0000000..a7eb0ef Binary files /dev/null and b/.vs/FakePieShop/FileContentIndex/2654b6c8-37aa-4614-a644-aea2f7465978.vsidx differ diff --git a/.vs/FakePieShop/FileContentIndex/513a647c-7412-445d-a6f2-a6c35475e756.vsidx b/.vs/FakePieShop/FileContentIndex/513a647c-7412-445d-a6f2-a6c35475e756.vsidx deleted file mode 100644 index cc10246..0000000 Binary files a/.vs/FakePieShop/FileContentIndex/513a647c-7412-445d-a6f2-a6c35475e756.vsidx and /dev/null differ diff --git a/.vs/FakePieShop/FileContentIndex/8f2aa4dd-b313-4449-838e-d6a6b8c66ef4.vsidx b/.vs/FakePieShop/FileContentIndex/8f2aa4dd-b313-4449-838e-d6a6b8c66ef4.vsidx deleted file mode 100644 index e6d32e1..0000000 Binary files a/.vs/FakePieShop/FileContentIndex/8f2aa4dd-b313-4449-838e-d6a6b8c66ef4.vsidx and /dev/null differ diff --git a/.vs/FakePieShop/FileContentIndex/b1ddaab6-6ab8-4a2a-9db2-21bbda54ae6a.vsidx b/.vs/FakePieShop/FileContentIndex/b1ddaab6-6ab8-4a2a-9db2-21bbda54ae6a.vsidx new file mode 100644 index 0000000..07f2f18 Binary files /dev/null and b/.vs/FakePieShop/FileContentIndex/b1ddaab6-6ab8-4a2a-9db2-21bbda54ae6a.vsidx differ diff --git a/.vs/FakePieShop/FileContentIndex/e48a1c16-6def-4559-89c5-f903cc281134.vsidx b/.vs/FakePieShop/FileContentIndex/e48a1c16-6def-4559-89c5-f903cc281134.vsidx new file mode 100644 index 0000000..1c31e6c Binary files /dev/null and b/.vs/FakePieShop/FileContentIndex/e48a1c16-6def-4559-89c5-f903cc281134.vsidx differ diff --git a/.vs/FakePieShop/v17/.suo b/.vs/FakePieShop/v17/.suo index 3122d2e..d3670a1 100644 Binary files a/.vs/FakePieShop/v17/.suo and b/.vs/FakePieShop/v17/.suo differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..3c1ab2f Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/FakePieShop/Controllers/PieController.cs b/FakePieShop/Controllers/PieController.cs deleted file mode 100644 index d0640b9..0000000 --- a/FakePieShop/Controllers/PieController.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -[Controller] -class PieController -{ - -} \ No newline at end of file diff --git a/FakePieShop/FakePieShop.csproj.user b/FakePieShop/FakePieShop.csproj.user new file mode 100644 index 0000000..e4f6e71 --- /dev/null +++ b/FakePieShop/FakePieShop.csproj.user @@ -0,0 +1,7 @@ + + + + MvcControllerEmptyScaffolder + root/Common/MVC/Controller + + \ No newline at end of file diff --git a/FakePieShop/Models/Category.cs b/FakePieShop/Models/Category.cs new file mode 100644 index 0000000..678626c --- /dev/null +++ b/FakePieShop/Models/Category.cs @@ -0,0 +1,10 @@ +namespace FakePieShop.Models +{ + public class Category + { + public int CategoryId { get; set; } + public string CategoryName { get; set; } = string.Empty; + public string? Description { get; set; } + public List? Pies { get; set; } + } +} diff --git a/FakePieShop/Models/ICategoryRepository.cs b/FakePieShop/Models/ICategoryRepository.cs new file mode 100644 index 0000000..47e94a3 --- /dev/null +++ b/FakePieShop/Models/ICategoryRepository.cs @@ -0,0 +1,7 @@ +namespace FakePieShop.Models +{ + public interface ICategoryRepository + { + IEnumerable AllCategories { get; } + } +} diff --git a/FakePieShop/Models/IPieRepository.cs b/FakePieShop/Models/IPieRepository.cs new file mode 100644 index 0000000..240bd81 --- /dev/null +++ b/FakePieShop/Models/IPieRepository.cs @@ -0,0 +1,9 @@ +namespace FakePieShop.Models +{ + public interface IPieRepository + { + IEnumerable AllPies { get; } + IEnumerable PiesOfTheWeek { get; } + Pie? GetPieById(int pieId); + } +} diff --git a/FakePieShop/Models/MockCategoryRepository.cs b/FakePieShop/Models/MockCategoryRepository.cs new file mode 100644 index 0000000..bfb88ee --- /dev/null +++ b/FakePieShop/Models/MockCategoryRepository.cs @@ -0,0 +1,13 @@ +namespace FakePieShop.Models +{ + public class MockCategoryRepository : ICategoryRepository + { + public IEnumerable AllCategories => + new List + { + new Category { CategoryId = 1, CategoryName = "Fruit pies", Description = "All-fruity pies" }, + new Category { CategoryId = 2, CategoryName = "Cheese cakes", Description = "Cheesy all the way" }, + new Category { CategoryId = 3, CategoryName = "Seasonal pies", Description = "Get in the mood for a seasonal pie" } + }; + } +} diff --git a/FakePieShop/Models/MockPieRepository.cs b/FakePieShop/Models/MockPieRepository.cs new file mode 100644 index 0000000..1a18e61 --- /dev/null +++ b/FakePieShop/Models/MockPieRepository.cs @@ -0,0 +1,65 @@ +namespace FakePieShop.Models +{ + public class MockPieRepository : IPieRepository + { + private readonly ICategoryRepository _categoryRepository = new MockCategoryRepository(); + + public IEnumerable AllPies + { + get + { + return new List + { + new Pie + { + PieId = 1, + Name = "Strawberry Pie", + Price = 15.95M, + ShortDescription = "Lorem Ipsum", + LongDescription = "Lorem Ipsum", + Category = _categoryRepository.AllCategories.ToList()[0], + ImageUrl = "https://gillcleerenpluralsight.blob.core.windows.net/files/strawberrypie.jpg", + InStock = true, + IsPieOfTheWeek = true, + ImageThumbnailUrl = "https://gillcleerenpluralsight.blob.core.windows.net/files/strawberrypiesmall.jpg" + }, + new Pie + { + PieId = 2, + Name = "Cheese cake", + Price = 18.95M, + ShortDescription = "Lorem Ipsum", + LongDescription = "Lorem Ipsum", + Category = _categoryRepository.AllCategories.ToList()[1], + ImageUrl = "https://gillcleerenpluralsight.blob.core.windows.net/files/cheesecake.jpg", + InStock = true, + IsPieOfTheWeek = false, + ImageThumbnailUrl = "https://gillcleerenpluralsight.blob.core.windows.net/files/cheesecakesmall.jpg" + }, + new Pie + { + PieId = 3 + } + }; + } + } + + public IEnumerable PiesOfTheWeek + { + get + { + return AllPies.Where(p => p.IsPieOfTheWeek); + } + } + + public Pie? GetPieById(int pieId) + { + return AllPies.FirstOrDefault(p => p.PieId == pieId); + } + + public IEnumerable SearchPies(string searchQuery) + { + throw new NotImplementedException(); + } + } +} diff --git a/FakePieShop/Models/Pie.cs b/FakePieShop/Models/Pie.cs new file mode 100644 index 0000000..a278ad0 --- /dev/null +++ b/FakePieShop/Models/Pie.cs @@ -0,0 +1,20 @@ +using System.ComponentModel; + +namespace FakePieShop.Models +{ + public class Pie + { + public int PieId { get; set; } + public string Name { get; set; } = String.Empty; + public string? ShortDescription { get; set; } + public string? LongDescription { get; set; } + public string? AllergyInformation { get; set; } + public decimal Price { get; set; } + public string? ImageUrl { get; set; } + public string? ImageThumbnailUrl { get; set; } + public bool IsPieOfTheWeek { get; set; } + public bool InStock { get; set; } + public int CategoryId { get; set; } + public Category Category { get; set; } = default!; + } +} \ No newline at end of file diff --git a/FakePieShop/Program.cs b/FakePieShop/Program.cs index 19bb1e5..c75a1ed 100644 --- a/FakePieShop/Program.cs +++ b/FakePieShop/Program.cs @@ -1,7 +1,11 @@ +using FakePieShop.Models; + WebApplicationBuilder builder = WebApplication.CreateBuilder(args); // add services to application builder.Services.AddControllersWithViews(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); WebApplication app = builder.Build(); diff --git a/FakePieShop/obj/Release/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs b/FakePieShop/obj/Release/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs new file mode 100644 index 0000000..ed92695 --- /dev/null +++ b/FakePieShop/obj/Release/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] diff --git a/FakePieShop/obj/Release/net6.0/FakePieShop.AssemblyInfo.cs b/FakePieShop/obj/Release/net6.0/FakePieShop.AssemblyInfo.cs new file mode 100644 index 0000000..9f7f25f --- /dev/null +++ b/FakePieShop/obj/Release/net6.0/FakePieShop.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("FakePieShop")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("FakePieShop")] +[assembly: System.Reflection.AssemblyTitleAttribute("FakePieShop")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/FakePieShop/obj/Release/net6.0/FakePieShop.AssemblyInfoInputs.cache b/FakePieShop/obj/Release/net6.0/FakePieShop.AssemblyInfoInputs.cache new file mode 100644 index 0000000..9b7b4a4 --- /dev/null +++ b/FakePieShop/obj/Release/net6.0/FakePieShop.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +8f4f401b3263a248ed5de2b5fc4f8ebb38be89a7 diff --git a/FakePieShop/obj/Release/net6.0/FakePieShop.GeneratedMSBuildEditorConfig.editorconfig b/FakePieShop/obj/Release/net6.0/FakePieShop.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..1c003f2 --- /dev/null +++ b/FakePieShop/obj/Release/net6.0/FakePieShop.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,17 @@ +is_global = true +build_property.TargetFramework = net6.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = FakePieShop +build_property.RootNamespace = FakePieShop +build_property.ProjectDir = C:\Users\mikay\source\repos\FakePieShop\FakePieShop\ +build_property.RazorLangVersion = 6.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\mikay\source\repos\FakePieShop\FakePieShop +build_property._RazorSourceGeneratorDebug = diff --git a/FakePieShop/obj/Release/net6.0/FakePieShop.GlobalUsings.g.cs b/FakePieShop/obj/Release/net6.0/FakePieShop.GlobalUsings.g.cs new file mode 100644 index 0000000..025530a --- /dev/null +++ b/FakePieShop/obj/Release/net6.0/FakePieShop.GlobalUsings.g.cs @@ -0,0 +1,17 @@ +// +global using global::Microsoft.AspNetCore.Builder; +global using global::Microsoft.AspNetCore.Hosting; +global using global::Microsoft.AspNetCore.Http; +global using global::Microsoft.AspNetCore.Routing; +global using global::Microsoft.Extensions.Configuration; +global using global::Microsoft.Extensions.DependencyInjection; +global using global::Microsoft.Extensions.Hosting; +global using global::Microsoft.Extensions.Logging; +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Net.Http.Json; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/FakePieShop/obj/Release/net6.0/FakePieShop.assets.cache b/FakePieShop/obj/Release/net6.0/FakePieShop.assets.cache new file mode 100644 index 0000000..e8a7b0c Binary files /dev/null and b/FakePieShop/obj/Release/net6.0/FakePieShop.assets.cache differ