Browse Source

catalog fake service is in place.

pull/73/head
Bill Wagner 8 years ago
parent
commit
2fdc6e2fd9
16 changed files with 189 additions and 0 deletions
  1. BIN
      docs/Migrating and deploying legacy monolithic .NET Framework applications to Windows containers .docx
  2. +10
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Catalog.WebForms.csproj
  3. BIN
      src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_01.png
  4. BIN
      src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_02.png
  5. BIN
      src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_03.png
  6. BIN
      src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_04.png
  7. BIN
      src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_05.png
  8. +28
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Extensions/ObservableExtensions.cs
  9. +4
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Global.asax.cs
  10. +13
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Models/CatalogBrand.cs
  11. +17
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Models/CatalogItem.cs
  12. +12
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Models/CatalogType.cs
  13. +75
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Services/CatalogMockService.cs
  14. +11
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Services/Common.cs
  15. +18
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Services/ICatalogService.cs
  16. +1
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/packages.config

BIN
docs/Migrating and deploying legacy monolithic .NET Framework applications to Windows containers .docx View File


+ 10
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Catalog.WebForms.csproj View File

@ -44,6 +44,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<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">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
@ -204,10 +207,17 @@
<Compile Include="Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="Extensions\ObservableExtensions.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Models\CatalogBrand.cs" />
<Compile Include="Models\CatalogItem.cs" />
<Compile Include="Models\CatalogType.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">
<DependentUpon>Site.Master</DependentUpon>
<SubType>ASPXCodeBehind</SubType>


BIN
src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_01.png View File

Before After
Width: 650  |  Height: 500  |  Size: 595 KiB

BIN
src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_02.png View File

Before After
Width: 650  |  Height: 500  |  Size: 560 KiB

BIN
src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_03.png View File

Before After
Width: 650  |  Height: 500  |  Size: 504 KiB

BIN
src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_04.png View File

Before After
Width: 650  |  Height: 427  |  Size: 81 KiB

BIN
src/Web/Catalog.WebForms/Catalog.WebForms/Content/fake_product_05.png View File

Before After
Width: 650  |  Height: 500  |  Size: 498 KiB

+ 28
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Extensions/ObservableExtensions.cs View File

@ -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;
}
}
}
}

+ 4
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Global.asax.cs View File

@ -16,6 +16,10 @@ namespace Microsoft.eShopOnContainers.Catalog.WebForms
// Code that runs on application startup
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
// Register Containers:
}
}
}

+ 13
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Models/CatalogBrand.cs View File

@ -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;
}
}

+ 17
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Models/CatalogItem.cs View File

@ -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; }
}
}

+ 12
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Models/CatalogType.cs View File

@ -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;
}
}

+ 75
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Services/CatalogMockService.cs View File

@ -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
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Services/Common.cs View 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";
}
}

+ 18
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Services/ICatalogService.cs View File

@ -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);
}
}

+ 1
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/packages.config View File

@ -3,6 +3,7 @@
<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.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="jQuery" version="1.10.2" targetFramework="net452" />
<package id="Microsoft.ApplicationInsights" version="2.2.0" targetFramework="net452" />


Loading…
Cancel
Save