catalog fake service is in place.
This commit is contained in:
parent
43cbd62784
commit
2fdc6e2fd9
Binary file not shown.
@ -44,6 +44,9 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Autofac, Version=4.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Autofac.4.3.0\lib\net45\Autofac.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -204,10 +207,17 @@
|
|||||||
<Compile Include="Default.aspx.designer.cs">
|
<Compile Include="Default.aspx.designer.cs">
|
||||||
<DependentUpon>Default.aspx</DependentUpon>
|
<DependentUpon>Default.aspx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Extensions\ObservableExtensions.cs" />
|
||||||
<Compile Include="Global.asax.cs">
|
<Compile Include="Global.asax.cs">
|
||||||
<DependentUpon>Global.asax</DependentUpon>
|
<DependentUpon>Global.asax</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Models\CatalogBrand.cs" />
|
||||||
|
<Compile Include="Models\CatalogItem.cs" />
|
||||||
|
<Compile Include="Models\CatalogType.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Services\CatalogMockService.cs" />
|
||||||
|
<Compile Include="Services\Common.cs" />
|
||||||
|
<Compile Include="Services\ICatalogService.cs" />
|
||||||
<Compile Include="Site.Master.cs">
|
<Compile Include="Site.Master.cs">
|
||||||
<DependentUpon>Site.Master</DependentUpon>
|
<DependentUpon>Site.Master</DependentUpon>
|
||||||
<SubType>ASPXCodeBehind</SubType>
|
<SubType>ASPXCodeBehind</SubType>
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 595 KiB |
Binary file not shown.
After Width: | Height: | Size: 560 KiB |
Binary file not shown.
After Width: | Height: | Size: 504 KiB |
Binary file not shown.
After Width: | Height: | Size: 81 KiB |
Binary file not shown.
After Width: | Height: | Size: 498 KiB |
@ -0,0 +1,28 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace eShopOnContainers.Core.Extensions
|
||||||
|
{
|
||||||
|
public static class ObservableExtension
|
||||||
|
{
|
||||||
|
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> source)
|
||||||
|
{
|
||||||
|
ObservableCollection<T> collection = new ObservableCollection<T>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (T item in source)
|
||||||
|
{
|
||||||
|
collection.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
// Really?
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,10 @@ namespace Microsoft.eShopOnContainers.Catalog.WebForms
|
|||||||
// Code that runs on application startup
|
// Code that runs on application startup
|
||||||
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
||||||
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
||||||
|
|
||||||
|
// Register Containers:
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
// Taken from https://github.com/dotnet/eShopOnContainers/blob/vs2017/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogBrand.cs
|
||||||
|
// Issue: How to make this DRY and still support the monolithic lift and shift scenario?
|
||||||
|
|
||||||
|
namespace eShopOnContainers.Core.Models.Catalog
|
||||||
|
{
|
||||||
|
public class CatalogBrand
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Brand { get; set; }
|
||||||
|
|
||||||
|
public override string ToString() => Brand;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
// Taken from https://github.com/dotnet/eShopOnContainers/blob/vs2017/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogItem.cs
|
||||||
|
// Issue: How to make this DRY and still support the monolithic lift and shift scenario?
|
||||||
|
namespace eShopOnContainers.Core.Models.Catalog
|
||||||
|
{
|
||||||
|
public class CatalogItem
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public decimal Price { get; set; }
|
||||||
|
public string PictureUri { get; set; }
|
||||||
|
public int CatalogBrandId { get; set; }
|
||||||
|
public string CatalogBrand { get; set; }
|
||||||
|
public int CatalogTypeId { get; set; }
|
||||||
|
public string CatalogType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
// Taken from https://github.com/dotnet/eShopOnContainers/blob/vs2017/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogType.cs
|
||||||
|
// Issue: How to make this DRY and still support the monolithic lift and shift scenario?
|
||||||
|
namespace eShopOnContainers.Core.Models.Catalog
|
||||||
|
{
|
||||||
|
public class CatalogType
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
public override string ToString() => Type;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
using eShopOnContainers.Core.Extensions;
|
||||||
|
using eShopOnContainers.Core.Models.Catalog;
|
||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace eShopOnContainers.Core.Services.Catalog
|
||||||
|
{
|
||||||
|
|
||||||
|
// From https://github.com/dotnet/eShopOnContainers/blob/vs2017/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs
|
||||||
|
// Issue: How to make this DRY, while preserving the story for a monolithic application.
|
||||||
|
// Note: Device specific conditionals have been removed.
|
||||||
|
public class CatalogMockService : ICatalogService
|
||||||
|
{
|
||||||
|
private ObservableCollection<CatalogBrand> MockCatalogBrand = new ObservableCollection<CatalogBrand>
|
||||||
|
{
|
||||||
|
new CatalogBrand { Id = 1, Brand = "Azure" },
|
||||||
|
new CatalogBrand { Id = 2, Brand = "Visual Studio" }
|
||||||
|
};
|
||||||
|
|
||||||
|
private ObservableCollection<CatalogType> MockCatalogType = new ObservableCollection<CatalogType>
|
||||||
|
{
|
||||||
|
new CatalogType { Id = 1, Type = "Mug" },
|
||||||
|
new CatalogType { Id = 2, Type = "T-Shirt" }
|
||||||
|
};
|
||||||
|
|
||||||
|
private ObservableCollection<CatalogItem> MockCatalog = new ObservableCollection<CatalogItem>
|
||||||
|
{
|
||||||
|
new CatalogItem { Id = Common.Common.MockCatalogItemId01, PictureUri = "Content/fake_product_01.png", Name = ".NET Bot Blue Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
||||||
|
new CatalogItem { Id = Common.Common.MockCatalogItemId02, PictureUri = "Content/fake_product_02.png", Name = ".NET Bot Purple Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
||||||
|
new CatalogItem { Id = Common.Common.MockCatalogItemId03, PictureUri = "Content/fake_product_03.png", Name = ".NET Bot Black Sweatshirt (M)", Price = 19.95M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
||||||
|
new CatalogItem { Id = Common.Common.MockCatalogItemId04, PictureUri = "Content/fake_product_04.png", Name = ".NET Black Cupt", Price = 17.00M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 1, CatalogType = "Mug" },
|
||||||
|
new CatalogItem { Id = Common.Common.MockCatalogItemId05, PictureUri = "Content/fake_product_05.png", Name = "Azure Black Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 1, CatalogBrand = "Azure", CatalogTypeId = 2, CatalogType = "T-Shirt" }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task<ObservableCollection<CatalogItem>> GetCatalogAsync()
|
||||||
|
{
|
||||||
|
await Task.Delay(500);
|
||||||
|
|
||||||
|
return MockCatalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ObservableCollection<CatalogItem>> FilterAsync(int catalogBrandId, int catalogTypeId)
|
||||||
|
{
|
||||||
|
await Task.Delay(500);
|
||||||
|
|
||||||
|
return MockCatalog
|
||||||
|
.Where(c => c.CatalogBrandId == catalogBrandId &&
|
||||||
|
c.CatalogTypeId == catalogTypeId)
|
||||||
|
.ToObservableCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ObservableCollection<CatalogBrand>> GetCatalogBrandAsync()
|
||||||
|
{
|
||||||
|
await Task.Delay(500);
|
||||||
|
|
||||||
|
return MockCatalogBrand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync()
|
||||||
|
{
|
||||||
|
await Task.Delay(500);
|
||||||
|
|
||||||
|
return MockCatalogType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<CatalogItem> GetCatalogItemAsync(string id)
|
||||||
|
{
|
||||||
|
await Task.Delay(500);
|
||||||
|
|
||||||
|
return MockCatalog.FirstOrDefault(c => c.Id == id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
src/Web/Catalog.WebForms/Catalog.WebForms/Services/Common.cs
Normal file
11
src/Web/Catalog.WebForms/Catalog.WebForms/Services/Common.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace eShopOnContainers.Core.Services.Common
|
||||||
|
{
|
||||||
|
public static class Common
|
||||||
|
{
|
||||||
|
public static string MockCatalogItemId01 = "1";
|
||||||
|
public static string MockCatalogItemId02 = "2";
|
||||||
|
public static string MockCatalogItemId03 = "3";
|
||||||
|
public static string MockCatalogItemId04 = "4";
|
||||||
|
public static string MockCatalogItemId05 = "5";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using eShopOnContainers.Core.Models.Catalog;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
// Taken from https://github.com/dotnet/eShopOnContainers/blob/vs2017/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs
|
||||||
|
// Open Issue: How do we make this application DRY and still support the story
|
||||||
|
// of a 'monolithic' app for a 'Lift and Shift' scenario?
|
||||||
|
namespace eShopOnContainers.Core.Services.Catalog
|
||||||
|
{
|
||||||
|
public interface ICatalogService
|
||||||
|
{
|
||||||
|
Task<ObservableCollection<CatalogBrand>> GetCatalogBrandAsync();
|
||||||
|
Task<ObservableCollection<CatalogItem>> FilterAsync(int catalogBrandId, int catalogTypeId);
|
||||||
|
Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync();
|
||||||
|
Task<ObservableCollection<CatalogItem>> GetCatalogAsync();
|
||||||
|
Task<CatalogItem> GetCatalogItemAsync(string id);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
<package id="Antlr" version="3.4.1.9004" targetFramework="net452" />
|
<package id="Antlr" version="3.4.1.9004" targetFramework="net452" />
|
||||||
<package id="AspNet.ScriptManager.bootstrap" version="3.0.0" targetFramework="net452" />
|
<package id="AspNet.ScriptManager.bootstrap" version="3.0.0" targetFramework="net452" />
|
||||||
<package id="AspNet.ScriptManager.jQuery" version="1.10.2" targetFramework="net452" />
|
<package id="AspNet.ScriptManager.jQuery" version="1.10.2" targetFramework="net452" />
|
||||||
|
<package id="Autofac" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="bootstrap" version="3.0.0" targetFramework="net452" />
|
<package id="bootstrap" version="3.0.0" targetFramework="net452" />
|
||||||
<package id="jQuery" version="1.10.2" targetFramework="net452" />
|
<package id="jQuery" version="1.10.2" targetFramework="net452" />
|
||||||
<package id="Microsoft.ApplicationInsights" version="2.2.0" targetFramework="net452" />
|
<package id="Microsoft.ApplicationInsights" version="2.2.0" targetFramework="net452" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user