Using dependency injection and viewmodel etc
This commit is contained in:
14
AdventureWorks.DataLayer/AdventureWorks.DataLayer.csproj
Normal file
14
AdventureWorks.DataLayer/AdventureWorks.DataLayer.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
|
||||||
|
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
75
AdventureWorks.DataLayer/DataClasses/ColorRepository.cs
Normal file
75
AdventureWorks.DataLayer/DataClasses/ColorRepository.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using AdventureWorks.EntityLayer;
|
||||||
|
using Common.Library;
|
||||||
|
|
||||||
|
namespace AdventureWorks.DataLayer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class creates some fake data for Colors.
|
||||||
|
/// </summary>
|
||||||
|
public partial class ColorRepository : IRepository<AdventureWorks.EntityLayer.Color>
|
||||||
|
{
|
||||||
|
#region Get Method
|
||||||
|
/// <summary>
|
||||||
|
/// Get all Color objects
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A list of Color objects</returns>
|
||||||
|
public ObservableCollection<AdventureWorks.EntityLayer.Color> Get()
|
||||||
|
{
|
||||||
|
return new ObservableCollection<AdventureWorks.EntityLayer.Color>
|
||||||
|
{
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 1,
|
||||||
|
ColorName = "Black",
|
||||||
|
},
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 2,
|
||||||
|
ColorName = "Blue",
|
||||||
|
},
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 3,
|
||||||
|
ColorName = "Gray",
|
||||||
|
},
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 4,
|
||||||
|
ColorName = "Multi",
|
||||||
|
},
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 5,
|
||||||
|
ColorName = "Red",
|
||||||
|
},
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 6,
|
||||||
|
ColorName = "Silver",
|
||||||
|
},
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 7,
|
||||||
|
ColorName = "Silver/Black",
|
||||||
|
},
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 8,
|
||||||
|
ColorName = "White",
|
||||||
|
},
|
||||||
|
new AdventureWorks.EntityLayer.Color {
|
||||||
|
ColorId = 9,
|
||||||
|
ColorName = "Yellow",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Get(id) Method
|
||||||
|
/// <summary>
|
||||||
|
/// Get a single Color object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The value to locate</param>
|
||||||
|
/// <returns>A valid Color object object, or null if not found</returns>
|
||||||
|
public AdventureWorks.EntityLayer.Color? Get(int id)
|
||||||
|
{
|
||||||
|
return Get().Where(row => row.ColorId == id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
51
AdventureWorks.DataLayer/DataClasses/PhoneTypeRepository.cs
Normal file
51
AdventureWorks.DataLayer/DataClasses/PhoneTypeRepository.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using AdventureWorks.EntityLayer;
|
||||||
|
using Common.Library;
|
||||||
|
|
||||||
|
namespace AdventureWorks.DataLayer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class creates some fake data for Phone Types.
|
||||||
|
/// </summary>
|
||||||
|
public partial class PhoneTypeRepository : IRepository<PhoneType>
|
||||||
|
{
|
||||||
|
#region Get Method
|
||||||
|
/// <summary>
|
||||||
|
/// Get all PhoneType objects
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A list of PhoneType objects</returns>
|
||||||
|
public ObservableCollection<PhoneType> Get()
|
||||||
|
{
|
||||||
|
return new ObservableCollection<PhoneType>
|
||||||
|
{
|
||||||
|
new PhoneType {
|
||||||
|
PhoneTypeId = 1,
|
||||||
|
TypeDescription = "Home",
|
||||||
|
},
|
||||||
|
new PhoneType {
|
||||||
|
PhoneTypeId = 2,
|
||||||
|
TypeDescription = "Mobile",
|
||||||
|
},
|
||||||
|
new PhoneType {
|
||||||
|
PhoneTypeId = 3,
|
||||||
|
TypeDescription = "Other",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Get(id) Method
|
||||||
|
/// <summary>
|
||||||
|
/// Get a single PhoneType object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The value to locate</param>
|
||||||
|
/// <returns>A valid PhoneType object object, or null if not found</returns>
|
||||||
|
public PhoneType? Get(int id)
|
||||||
|
{
|
||||||
|
return Get().Where(row => row.PhoneTypeId == id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
519
AdventureWorks.DataLayer/DataClasses/ProductRepository.cs
Normal file
519
AdventureWorks.DataLayer/DataClasses/ProductRepository.cs
Normal file
@ -0,0 +1,519 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using AdventureWorks.EntityLayer;
|
||||||
|
using Common.Library;
|
||||||
|
|
||||||
|
namespace AdventureWorks.DataLayer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class creates some fake data for Products.
|
||||||
|
/// </summary>
|
||||||
|
public partial class ProductRepository : IRepository<Product>
|
||||||
|
{
|
||||||
|
#region Get Method
|
||||||
|
/// <summary>
|
||||||
|
/// Get all Product objects
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A list of Product objects</returns>
|
||||||
|
public ObservableCollection<Product> Get()
|
||||||
|
{
|
||||||
|
return new ObservableCollection<Product>
|
||||||
|
{
|
||||||
|
new Product {
|
||||||
|
ProductID = 680,
|
||||||
|
Name = @"HL Road Frame - Black, 58",
|
||||||
|
ProductNumber = @"FR-R92B-58",
|
||||||
|
Color = @"Black",
|
||||||
|
StandardCost = 1059.3100m,
|
||||||
|
ListPrice = 1431.5000m,
|
||||||
|
Size = @"58",
|
||||||
|
Weight = 1016.04m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 6,
|
||||||
|
SellStartDate = Convert.ToDateTime("6/1/2002 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 706,
|
||||||
|
Name = @"HL Road Frame - Red, 58",
|
||||||
|
ProductNumber = @"FR-R92R-58",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 1059.3100m,
|
||||||
|
ListPrice = 1431.5000m,
|
||||||
|
Size = @"58",
|
||||||
|
Weight = 1016.04m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 6,
|
||||||
|
SellStartDate = Convert.ToDateTime("6/1/2002 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 707,
|
||||||
|
Name = @"Sport-100 Helmet, Red",
|
||||||
|
ProductNumber = @"HL-U509-R",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 13.0863m,
|
||||||
|
ListPrice = 34.9900m,
|
||||||
|
Size = string.Empty,
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 35,
|
||||||
|
ProductModelID = 33,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 708,
|
||||||
|
Name = @"Sport-100 Helmet, Black",
|
||||||
|
ProductNumber = @"HL-U509",
|
||||||
|
Color = @"Black",
|
||||||
|
StandardCost = 13.0863m,
|
||||||
|
ListPrice = 34.9900m,
|
||||||
|
Size = string.Empty,
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 35,
|
||||||
|
ProductModelID = 33,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 709,
|
||||||
|
Name = @"Mountain Bike Socks, M",
|
||||||
|
ProductNumber = @"SO-B909-M",
|
||||||
|
Color = @"White",
|
||||||
|
StandardCost = 3.3963m,
|
||||||
|
ListPrice = 9.5000m,
|
||||||
|
Size = @"M",
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 27,
|
||||||
|
ProductModelID = 18,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2006 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 710,
|
||||||
|
Name = @"Mountain Bike Socks, L",
|
||||||
|
ProductNumber = @"SO-B909-L",
|
||||||
|
Color = @"White",
|
||||||
|
StandardCost = 3.3963m,
|
||||||
|
ListPrice = 9.5000m,
|
||||||
|
Size = @"L",
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 27,
|
||||||
|
ProductModelID = 18,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2006 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 711,
|
||||||
|
Name = @"Sport-100 Helmet, Blue",
|
||||||
|
ProductNumber = @"HL-U509-B",
|
||||||
|
Color = @"Blue",
|
||||||
|
StandardCost = 13.0863m,
|
||||||
|
ListPrice = 34.9900m,
|
||||||
|
Size = string.Empty,
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 35,
|
||||||
|
ProductModelID = 33,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 712,
|
||||||
|
Name = @"AWC Logo Cap",
|
||||||
|
ProductNumber = @"CA-1098",
|
||||||
|
Color = @"Multi",
|
||||||
|
StandardCost = 6.9223m,
|
||||||
|
ListPrice = 8.9900m,
|
||||||
|
Size = string.Empty,
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 23,
|
||||||
|
ProductModelID = 2,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 713,
|
||||||
|
Name = @"Long-Sleeve Logo Jersey, S",
|
||||||
|
ProductNumber = @"LJ-0192-S",
|
||||||
|
Color = @"Multi",
|
||||||
|
StandardCost = 38.4923m,
|
||||||
|
ListPrice = 49.9900m,
|
||||||
|
Size = @"S",
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 25,
|
||||||
|
ProductModelID = 11,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 714,
|
||||||
|
Name = @"Long-Sleeve Logo Jersey, M",
|
||||||
|
ProductNumber = @"LJ-0192-M",
|
||||||
|
Color = @"Multi",
|
||||||
|
StandardCost = 38.4923m,
|
||||||
|
ListPrice = 49.9900m,
|
||||||
|
Size = @"M",
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 25,
|
||||||
|
ProductModelID = 11,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 715,
|
||||||
|
Name = @"Long-Sleeve Logo Jersey, L",
|
||||||
|
ProductNumber = @"LJ-0192-L",
|
||||||
|
Color = @"Multi",
|
||||||
|
StandardCost = 38.4923m,
|
||||||
|
ListPrice = 49.9900m,
|
||||||
|
Size = @"L",
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 25,
|
||||||
|
ProductModelID = 11,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 716,
|
||||||
|
Name = @"Long-Sleeve Logo Jersey, XL",
|
||||||
|
ProductNumber = @"LJ-0192-X",
|
||||||
|
Color = @"Multi",
|
||||||
|
StandardCost = 38.4923m,
|
||||||
|
ListPrice = 49.9900m,
|
||||||
|
Size = @"XL",
|
||||||
|
Weight = null,
|
||||||
|
ProductCategoryID = 25,
|
||||||
|
ProductModelID = 11,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 717,
|
||||||
|
Name = @"HL Road Frame - Red, 62",
|
||||||
|
ProductNumber = @"FR-R92R-62",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 868.6342m,
|
||||||
|
ListPrice = 1431.5000m,
|
||||||
|
Size = @"62",
|
||||||
|
Weight = 1043.26m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 6,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 718,
|
||||||
|
Name = @"HL Road Frame - Red, 44",
|
||||||
|
ProductNumber = @"FR-R92R-44",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 868.6342m,
|
||||||
|
ListPrice = 1431.5000m,
|
||||||
|
Size = @"44",
|
||||||
|
Weight = 961.61m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 6,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 719,
|
||||||
|
Name = @"HL Road Frame - Red, 48",
|
||||||
|
ProductNumber = @"FR-R92R-48",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 868.6342m,
|
||||||
|
ListPrice = 1431.5000m,
|
||||||
|
Size = @"48",
|
||||||
|
Weight = 979.75m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 6,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 720,
|
||||||
|
Name = @"HL Road Frame - Red, 52",
|
||||||
|
ProductNumber = @"FR-R92R-52",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 868.6342m,
|
||||||
|
ListPrice = 1431.5000m,
|
||||||
|
Size = @"52",
|
||||||
|
Weight = 997.90m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 6,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 721,
|
||||||
|
Name = @"HL Road Frame - Red, 56",
|
||||||
|
ProductNumber = @"FR-R92R-56",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 868.6342m,
|
||||||
|
ListPrice = 1431.5000m,
|
||||||
|
Size = @"56",
|
||||||
|
Weight = 1016.04m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 6,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 722,
|
||||||
|
Name = @"LL Road Frame - Black, 58",
|
||||||
|
ProductNumber = @"FR-R38B-58",
|
||||||
|
Color = @"Black",
|
||||||
|
StandardCost = 204.6251m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"58",
|
||||||
|
Weight = 1115.83m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 723,
|
||||||
|
Name = @"LL Road Frame - Black, 60",
|
||||||
|
ProductNumber = @"FR-R38B-60",
|
||||||
|
Color = @"Black",
|
||||||
|
StandardCost = 204.6251m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"60",
|
||||||
|
Weight = 1124.90m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 724,
|
||||||
|
Name = @"LL Road Frame - Black, 62",
|
||||||
|
ProductNumber = @"FR-R38B-62",
|
||||||
|
Color = @"Black",
|
||||||
|
StandardCost = 204.6251m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"62",
|
||||||
|
Weight = 1133.98m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = null,
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 725,
|
||||||
|
Name = @"LL Road Frame - Red, 44",
|
||||||
|
ProductNumber = @"FR-R38R-44",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 187.1571m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"44",
|
||||||
|
Weight = 1052.33m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2007 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 726,
|
||||||
|
Name = @"LL Road Frame - Red, 48",
|
||||||
|
ProductNumber = @"FR-R38R-48",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 187.1571m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"48",
|
||||||
|
Weight = 1070.47m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2007 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 727,
|
||||||
|
Name = @"LL Road Frame - Red, 52",
|
||||||
|
ProductNumber = @"FR-R38R-52",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 187.1571m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"52",
|
||||||
|
Weight = 1088.62m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2007 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 728,
|
||||||
|
Name = @"LL Road Frame - Red, 58",
|
||||||
|
ProductNumber = @"FR-R38R-58",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 187.1571m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"58",
|
||||||
|
Weight = 1115.83m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2007 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 729,
|
||||||
|
Name = @"LL Road Frame - Red, 60",
|
||||||
|
ProductNumber = @"FR-R38R-60",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 187.1571m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"60",
|
||||||
|
Weight = 1124.90m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2007 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 730,
|
||||||
|
Name = @"LL Road Frame - Red, 62",
|
||||||
|
ProductNumber = @"FR-R38R-62",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 187.1571m,
|
||||||
|
ListPrice = 337.2200m,
|
||||||
|
Size = @"62",
|
||||||
|
Weight = 1133.98m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 9,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2007 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 731,
|
||||||
|
Name = @"ML Road Frame - Red, 44",
|
||||||
|
ProductNumber = @"FR-R72R-44",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 352.1394m,
|
||||||
|
ListPrice = 594.8300m,
|
||||||
|
Size = @"44",
|
||||||
|
Weight = 1006.97m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 16,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2006 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 732,
|
||||||
|
Name = @"ML Road Frame - Red, 48",
|
||||||
|
ProductNumber = @"FR-R72R-48",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 352.1394m,
|
||||||
|
ListPrice = 594.8300m,
|
||||||
|
Size = @"48",
|
||||||
|
Weight = 1025.11m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 16,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2006 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 733,
|
||||||
|
Name = @"ML Road Frame - Red, 52",
|
||||||
|
ProductNumber = @"FR-R72R-52",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 352.1394m,
|
||||||
|
ListPrice = 594.8300m,
|
||||||
|
Size = @"52",
|
||||||
|
Weight = 1043.26m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 16,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2006 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
},
|
||||||
|
new Product {
|
||||||
|
ProductID = 734,
|
||||||
|
Name = @"ML Road Frame - Red, 58",
|
||||||
|
ProductNumber = @"FR-R72R-58",
|
||||||
|
Color = @"Red",
|
||||||
|
StandardCost = 352.1394m,
|
||||||
|
ListPrice = 594.8300m,
|
||||||
|
Size = @"58",
|
||||||
|
Weight = 1070.47m,
|
||||||
|
ProductCategoryID = 18,
|
||||||
|
ProductModelID = 16,
|
||||||
|
SellStartDate = Convert.ToDateTime("7/1/2005 12:00:00 AM"),
|
||||||
|
SellEndDate = Convert.ToDateTime("6/30/2006 12:00:00 AM"),
|
||||||
|
DiscontinuedDate = null,
|
||||||
|
ModifiedDate = Convert.ToDateTime("3/11/2008 10:01:36 AM"),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Get(id) Method
|
||||||
|
/// <summary>
|
||||||
|
/// Get a single Product object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The value to locate</param>
|
||||||
|
/// <returns>A valid Product object object, or null if not found</returns>
|
||||||
|
public Product? Get(int id)
|
||||||
|
{
|
||||||
|
return Get().Where(row => row.ProductID == id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
163
AdventureWorks.DataLayer/DataClasses/UserRepository.cs
Normal file
163
AdventureWorks.DataLayer/DataClasses/UserRepository.cs
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
using AdventureWorks.EntityLayer;
|
||||||
|
using Common.Library;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace AdventureWorks.DataLayer;
|
||||||
|
|
||||||
|
public partial class UserRepository : IRepository<User>
|
||||||
|
{
|
||||||
|
#region Get Method
|
||||||
|
public ObservableCollection<User> Get()
|
||||||
|
{
|
||||||
|
// This method should return a collection of User objects.
|
||||||
|
// For now, returning an empty collection.
|
||||||
|
return new ObservableCollection<User>()
|
||||||
|
{
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
UserId = 1,
|
||||||
|
LoginId = @"SallyJones615",
|
||||||
|
FirstName = @"Sally",
|
||||||
|
LastName = @"Jones",
|
||||||
|
Email = @"sally@jones.com",
|
||||||
|
Password = @"password123",
|
||||||
|
Phone = @"555-1234",
|
||||||
|
PhoneType = @"Mobile",
|
||||||
|
IsFullTime = true,
|
||||||
|
IsEnrolledIn401k = false,
|
||||||
|
IsEnrolledInFlexTime = false,
|
||||||
|
IsEnrolledInHealthCare = true,
|
||||||
|
IsEnrolledInHSA = false,
|
||||||
|
IsActive = true,
|
||||||
|
BirthDate = Convert.ToDateTime("1975-11-04"),
|
||||||
|
StartTime = new TimeSpan(8, 0, 0)
|
||||||
|
},
|
||||||
|
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
UserId = 2,
|
||||||
|
LoginId = @"SallyJones615",
|
||||||
|
FirstName = @"Sally",
|
||||||
|
LastName = @"Jones",
|
||||||
|
Email = @"sally@jones.com",
|
||||||
|
Password = @"password123",
|
||||||
|
Phone = @"555-1234",
|
||||||
|
PhoneType = @"Mobile",
|
||||||
|
IsFullTime = true,
|
||||||
|
IsEnrolledIn401k = false,
|
||||||
|
IsEnrolledInFlexTime = false,
|
||||||
|
IsEnrolledInHealthCare = true,
|
||||||
|
IsEnrolledInHSA = false,
|
||||||
|
IsActive = true,
|
||||||
|
BirthDate = Convert.ToDateTime("1975-11-04"),
|
||||||
|
StartTime = new TimeSpan(8, 0, 0)
|
||||||
|
},
|
||||||
|
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
UserId = 3,
|
||||||
|
LoginId = @"SallyJones615",
|
||||||
|
FirstName = @"Sally",
|
||||||
|
LastName = @"Jones",
|
||||||
|
Email = @"sally@jones.com",
|
||||||
|
Password = @"password123",
|
||||||
|
Phone = @"555-1234",
|
||||||
|
PhoneType = @"Mobile",
|
||||||
|
IsFullTime = true,
|
||||||
|
IsEnrolledIn401k = false,
|
||||||
|
IsEnrolledInFlexTime = false,
|
||||||
|
IsEnrolledInHealthCare = true,
|
||||||
|
IsEnrolledInHSA = false,
|
||||||
|
IsActive = true,
|
||||||
|
BirthDate = Convert.ToDateTime("1975-11-04"),
|
||||||
|
StartTime = new TimeSpan(8, 0, 0)
|
||||||
|
},
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
UserId = 3,
|
||||||
|
LoginId = @"SallyJones615",
|
||||||
|
FirstName = @"Sally",
|
||||||
|
LastName = @"Jones",
|
||||||
|
Email = @"sally@jones.com",
|
||||||
|
Password = @"password123",
|
||||||
|
Phone = @"555-1234",
|
||||||
|
PhoneType = @"Mobile",
|
||||||
|
IsFullTime = true,
|
||||||
|
IsEnrolledIn401k = false,
|
||||||
|
IsEnrolledInFlexTime = false,
|
||||||
|
IsEnrolledInHealthCare = true,
|
||||||
|
IsEnrolledInHSA = false,
|
||||||
|
IsActive = true,
|
||||||
|
BirthDate = Convert.ToDateTime("1975-11-04"),
|
||||||
|
StartTime = new TimeSpan(8, 0, 0)
|
||||||
|
},
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
UserId = 4,
|
||||||
|
LoginId = @"SallyJones615",
|
||||||
|
FirstName = @"Sally",
|
||||||
|
LastName = @"Jones",
|
||||||
|
Email = @"sally@jones.com",
|
||||||
|
Password = @"password123",
|
||||||
|
Phone = @"555-1234",
|
||||||
|
PhoneType = @"Mobile",
|
||||||
|
IsFullTime = true,
|
||||||
|
IsEnrolledIn401k = false,
|
||||||
|
IsEnrolledInFlexTime = false,
|
||||||
|
IsEnrolledInHealthCare = true,
|
||||||
|
IsEnrolledInHSA = false,
|
||||||
|
IsActive = true,
|
||||||
|
BirthDate = Convert.ToDateTime("1975-11-04"),
|
||||||
|
StartTime = new TimeSpan(8, 0, 0)
|
||||||
|
},
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
UserId = 5,
|
||||||
|
LoginId = @"SallyJones615",
|
||||||
|
FirstName = @"Sally",
|
||||||
|
LastName = @"Jones",
|
||||||
|
Email = @"sally@jones.com",
|
||||||
|
Password = @"password123",
|
||||||
|
Phone = @"555-1234",
|
||||||
|
PhoneType = @"Mobile",
|
||||||
|
IsFullTime = true,
|
||||||
|
IsEnrolledIn401k = false,
|
||||||
|
IsEnrolledInFlexTime = false,
|
||||||
|
IsEnrolledInHealthCare = true,
|
||||||
|
IsEnrolledInHSA = false,
|
||||||
|
IsActive = true,
|
||||||
|
BirthDate = Convert.ToDateTime("1975-11-04"),
|
||||||
|
StartTime = new TimeSpan(8, 0, 0)
|
||||||
|
},
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
UserId = 6,
|
||||||
|
LoginId = @"SallyJones615",
|
||||||
|
FirstName = @"Sally",
|
||||||
|
LastName = @"Jones",
|
||||||
|
Email = @"sally@jones.com",
|
||||||
|
Password = @"password123",
|
||||||
|
Phone = @"555-1234",
|
||||||
|
PhoneType = @"Mobile",
|
||||||
|
IsFullTime = true,
|
||||||
|
IsEnrolledIn401k = false,
|
||||||
|
IsEnrolledInFlexTime = false,
|
||||||
|
IsEnrolledInHealthCare = true,
|
||||||
|
IsEnrolledInHSA = false,
|
||||||
|
IsActive = true,
|
||||||
|
BirthDate = Convert.ToDateTime("1975-11-04"),
|
||||||
|
StartTime = new TimeSpan(8, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public User? Get(int id)
|
||||||
|
{
|
||||||
|
return Get().Where(row => row.UserId == id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
33
AdventureWorks.EntityLayer/EntityClasses/Color.cs
Normal file
33
AdventureWorks.EntityLayer/EntityClasses/Color.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using Common.Library;
|
||||||
|
|
||||||
|
namespace AdventureWorks.EntityLayer;
|
||||||
|
|
||||||
|
public class Color : EntityBase
|
||||||
|
{
|
||||||
|
#region Private Variables
|
||||||
|
private int _ColorId;
|
||||||
|
private string _ColorName = string.Empty;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
public int ColorId
|
||||||
|
{
|
||||||
|
get { return _ColorId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_ColorId = value;
|
||||||
|
RaisePropertyChanged(nameof(ColorId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ColorName
|
||||||
|
{
|
||||||
|
get { return _ColorName; }
|
||||||
|
set {
|
||||||
|
_ColorName = value;
|
||||||
|
RaisePropertyChanged(nameof(ColorName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
32
AdventureWorks.EntityLayer/EntityClasses/PhoneType.cs
Normal file
32
AdventureWorks.EntityLayer/EntityClasses/PhoneType.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using Common.Library;
|
||||||
|
|
||||||
|
namespace AdventureWorks.EntityLayer;
|
||||||
|
|
||||||
|
public class PhoneType : EntityBase
|
||||||
|
{
|
||||||
|
#region Private Variables
|
||||||
|
private int _PhoneTypeId;
|
||||||
|
private string _TypeDescription = string.Empty;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
public int PhoneTypeId
|
||||||
|
{
|
||||||
|
get { return _PhoneTypeId; }
|
||||||
|
set {
|
||||||
|
_PhoneTypeId = value;
|
||||||
|
RaisePropertyChanged(nameof(PhoneTypeId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TypeDescription
|
||||||
|
{
|
||||||
|
get { return _TypeDescription; }
|
||||||
|
set {
|
||||||
|
_TypeDescription = value;
|
||||||
|
RaisePropertyChanged(nameof(TypeDescription));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
152
AdventureWorks.EntityLayer/EntityClasses/Product.cs
Normal file
152
AdventureWorks.EntityLayer/EntityClasses/Product.cs
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
using System;
|
||||||
|
using Common.Library;
|
||||||
|
|
||||||
|
namespace AdventureWorks.EntityLayer;
|
||||||
|
|
||||||
|
public partial class Product : EntityBase
|
||||||
|
{
|
||||||
|
#region Private Variables
|
||||||
|
private int _ProductID;
|
||||||
|
private string _Name = string.Empty;
|
||||||
|
private string _ProductNumber = string.Empty;
|
||||||
|
private string _Color = string.Empty;
|
||||||
|
private decimal _StandardCost;
|
||||||
|
private decimal _ListPrice;
|
||||||
|
private string _Size = string.Empty;
|
||||||
|
private decimal? _Weight;
|
||||||
|
private int? _ProductCategoryID;
|
||||||
|
private int? _ProductModelID;
|
||||||
|
private DateTime _SellStartDate;
|
||||||
|
private DateTime? _SellEndDate;
|
||||||
|
private DateTime? _DiscontinuedDate;
|
||||||
|
private DateTime _ModifiedDate;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
public int ProductID
|
||||||
|
{
|
||||||
|
get { return _ProductID; }
|
||||||
|
set {
|
||||||
|
_ProductID = value;
|
||||||
|
RaisePropertyChanged(nameof(ProductID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return _Name; }
|
||||||
|
set {
|
||||||
|
_Name = value;
|
||||||
|
RaisePropertyChanged(nameof(Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ProductNumber
|
||||||
|
{
|
||||||
|
get { return _ProductNumber; }
|
||||||
|
set {
|
||||||
|
_ProductNumber = value;
|
||||||
|
RaisePropertyChanged(nameof(ProductNumber));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Color
|
||||||
|
{
|
||||||
|
get { return _Color; }
|
||||||
|
set {
|
||||||
|
_Color = value;
|
||||||
|
RaisePropertyChanged(nameof(Color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal StandardCost
|
||||||
|
{
|
||||||
|
get { return _StandardCost; }
|
||||||
|
set {
|
||||||
|
_StandardCost = value;
|
||||||
|
RaisePropertyChanged(nameof(StandardCost));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal ListPrice
|
||||||
|
{
|
||||||
|
get { return _ListPrice; }
|
||||||
|
set {
|
||||||
|
_ListPrice = value;
|
||||||
|
RaisePropertyChanged(nameof(ListPrice));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Size
|
||||||
|
{
|
||||||
|
get { return _Size; }
|
||||||
|
set {
|
||||||
|
_Size = value;
|
||||||
|
RaisePropertyChanged(nameof(Size));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal? Weight
|
||||||
|
{
|
||||||
|
get { return _Weight; }
|
||||||
|
set {
|
||||||
|
_Weight = value;
|
||||||
|
RaisePropertyChanged(nameof(Weight));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? ProductCategoryID
|
||||||
|
{
|
||||||
|
get { return _ProductCategoryID; }
|
||||||
|
set {
|
||||||
|
_ProductCategoryID = value;
|
||||||
|
RaisePropertyChanged(nameof(ProductCategoryID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? ProductModelID
|
||||||
|
{
|
||||||
|
get { return _ProductModelID; }
|
||||||
|
set {
|
||||||
|
_ProductModelID = value;
|
||||||
|
RaisePropertyChanged(nameof(ProductModelID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime SellStartDate
|
||||||
|
{
|
||||||
|
get { return _SellStartDate; }
|
||||||
|
set {
|
||||||
|
_SellStartDate = value;
|
||||||
|
RaisePropertyChanged(nameof(SellStartDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime? SellEndDate
|
||||||
|
{
|
||||||
|
get { return _SellEndDate; }
|
||||||
|
set {
|
||||||
|
_SellEndDate = value;
|
||||||
|
RaisePropertyChanged(nameof(SellEndDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime? DiscontinuedDate
|
||||||
|
{
|
||||||
|
get { return _DiscontinuedDate; }
|
||||||
|
set {
|
||||||
|
_DiscontinuedDate = value;
|
||||||
|
RaisePropertyChanged(nameof(DiscontinuedDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime ModifiedDate
|
||||||
|
{
|
||||||
|
get { return _ModifiedDate; }
|
||||||
|
set {
|
||||||
|
_ModifiedDate = value;
|
||||||
|
RaisePropertyChanged(nameof(ModifiedDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Library", "Common.Li
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.ViewModelLayer", "AdventureWorks.ViewModelLayer\AdventureWorks.ViewModelLayer.csproj", "{3E3C685B-CA66-4E12-83BC-B872BC5FD933}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.ViewModelLayer", "AdventureWorks.ViewModelLayer\AdventureWorks.ViewModelLayer.csproj", "{3E3C685B-CA66-4E12-83BC-B872BC5FD933}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.DataLayer", "AdventureWorks.DataLayer\AdventureWorks.DataLayer.csproj", "{BE1C17A0-A605-451E-822D-230216754875}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -34,6 +36,10 @@ Global
|
|||||||
{3E3C685B-CA66-4E12-83BC-B872BC5FD933}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3E3C685B-CA66-4E12-83BC-B872BC5FD933}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3E3C685B-CA66-4E12-83BC-B872BC5FD933}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3E3C685B-CA66-4E12-83BC-B872BC5FD933}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3E3C685B-CA66-4E12-83BC-B872BC5FD933}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3E3C685B-CA66-4E12-83BC-B872BC5FD933}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BE1C17A0-A605-451E-822D-230216754875}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BE1C17A0-A605-451E-822D-230216754875}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BE1C17A0-A605-451E-822D-230216754875}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BE1C17A0-A605-451E-822D-230216754875}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -65,6 +65,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AdventureWorks.DataLayer\AdventureWorks.DataLayer.csproj" />
|
||||||
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
|
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
|
||||||
<ProjectReference Include="..\AdventureWorks.ViewModelLayer\AdventureWorks.ViewModelLayer.csproj" />
|
<ProjectReference Include="..\AdventureWorks.ViewModelLayer\AdventureWorks.ViewModelLayer.csproj" />
|
||||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||||
|
|||||||
@ -5,11 +5,6 @@
|
|||||||
x:Class="AdventureWorks.MAUI.App">
|
x:Class="AdventureWorks.MAUI.App">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<x:Array x:Key="phoneTypes" Type="{x:Type x:String}">
|
|
||||||
<x:String>Home</x:String>
|
|
||||||
<x:String>Mobile</x:String>
|
|
||||||
<x:String>Other</x:String>
|
|
||||||
</x:Array>
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
|
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
|
||||||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
|
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using AdventureWorks.DataLayer;
|
||||||
|
using AdventureWorks.EntityLayer;
|
||||||
|
using AdventureWorks.MAUI.Views;
|
||||||
|
using AdventureWorks.ViewModelLayer;
|
||||||
|
using Common.Library;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
//#if Windows
|
//#if Windows
|
||||||
using Microsoft.Maui.LifecycleEvents;
|
using Microsoft.Maui.LifecycleEvents;
|
||||||
@ -18,7 +23,12 @@ namespace AdventureWorks.MAUI
|
|||||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
||||||
});
|
});
|
||||||
|
//DI Services
|
||||||
|
builder.Services.AddScoped<IRepository<User>, UserRepository>();
|
||||||
|
builder.Services.AddScoped<IRepository<EntityLayer.Color>, ColorRepository>();
|
||||||
|
builder.Services.AddScoped<IRepository<PhoneType>, PhoneTypeRepository>();
|
||||||
|
builder.Services.AddScoped<UserViewModel>();
|
||||||
|
builder.Services.AddScoped<UserDetailView>();
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
SetWindowOptions(builder);
|
SetWindowOptions(builder);
|
||||||
SetWindowHandlers();
|
SetWindowHandlers();
|
||||||
|
|||||||
@ -135,7 +135,7 @@
|
|||||||
Text="{Binding UserObject.Phone}"/>
|
Text="{Binding UserObject.Phone}"/>
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
<HorizontalStackLayout>
|
<HorizontalStackLayout>
|
||||||
<Picker ItemsSource="{StaticResource UserObject.phoneTypes}"
|
<Picker ItemsSource="{Binding PhoneTypesList}"
|
||||||
SelectedItem="{Binding UserObject.PhoneType}"/>
|
SelectedItem="{Binding UserObject.PhoneType}"/>
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
</FlexLayout>
|
</FlexLayout>
|
||||||
|
|||||||
@ -3,10 +3,10 @@ namespace AdventureWorks.MAUI.Views;
|
|||||||
|
|
||||||
public partial class UserDetailView : ContentPage
|
public partial class UserDetailView : ContentPage
|
||||||
{
|
{
|
||||||
public UserDetailView()
|
public UserDetailView(UserViewModel viewModel)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
ViewModel = viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserViewModel ViewModel { get; set; }
|
public UserViewModel ViewModel { get; set; }
|
||||||
@ -15,10 +15,10 @@ public partial class UserDetailView : ContentPage
|
|||||||
{
|
{
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
|
|
||||||
ViewModel = new();
|
|
||||||
|
|
||||||
BindingContext = ViewModel;
|
BindingContext = ViewModel;
|
||||||
|
|
||||||
|
ViewModel.GetPhoneTypes();
|
||||||
|
|
||||||
ViewModel.Get(1); // Assuming you want to get the user with ID 1
|
ViewModel.Get(1); // Assuming you want to get the user with ID 1
|
||||||
}
|
}
|
||||||
private void SaveButton_Clicked(object sender, EventArgs e)
|
private void SaveButton_Clicked(object sender, EventArgs e)
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AdventureWorks.DataLayer\AdventureWorks.DataLayer.csproj" />
|
||||||
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
|
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
|
||||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@ -6,8 +6,28 @@ namespace AdventureWorks.ViewModelLayer;
|
|||||||
|
|
||||||
public class UserViewModel : ViewModelBase
|
public class UserViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
#region Constructors
|
||||||
|
public UserViewModel() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserViewModel(IRepository<User> repo) : base()
|
||||||
|
{
|
||||||
|
Repository = repo;
|
||||||
|
}
|
||||||
|
public UserViewModel(IRepository<User> repo, IRepository<PhoneType> phoneRepo)
|
||||||
|
{
|
||||||
|
Repository = repo;
|
||||||
|
_PhoneTypeRepository = phoneRepo;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Variables
|
#region Private Variables
|
||||||
private User? _UserObject = new();
|
private User? _UserObject = new();
|
||||||
|
private readonly IRepository<User>? Repository;
|
||||||
|
private readonly IRepository<PhoneType>? _PhoneTypeRepository;
|
||||||
|
private ObservableCollection<string> _PhoneTypesList = new();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public Properties
|
#region public Properties
|
||||||
@ -22,6 +42,18 @@ public class UserViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<string> PhoneTypesList
|
||||||
|
{
|
||||||
|
get { return _PhoneTypesList; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_PhoneTypesList = value;
|
||||||
|
RaisePropertyChanged(nameof(PhoneTypesList));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Get Method
|
#region Get Method
|
||||||
@ -37,26 +69,34 @@ public class UserViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UserObject = new User
|
if (Repository != null)
|
||||||
{
|
{
|
||||||
UserId = id,
|
UserObject = Repository.Get(id);
|
||||||
LoginId = "SallyJones615",
|
}
|
||||||
FirstName = "Sally",
|
else
|
||||||
LastName = "Jones",
|
{
|
||||||
Email = "sally@jones.com",
|
UserObject = new User
|
||||||
Password = "password123",
|
{
|
||||||
Phone = "555-1234",
|
|
||||||
PhoneType = "Mobile",
|
|
||||||
IsFullTime = true,
|
|
||||||
IsEnrolledIn401k = false,
|
|
||||||
IsEnrolledInFlexTime = false,
|
|
||||||
IsEnrolledInHealthCare = true,
|
|
||||||
IsEnrolledInHSA = false,
|
|
||||||
IsActive = true,
|
|
||||||
BirthDate = Convert.ToDateTime("1975-11-04"),
|
|
||||||
StartTime = new TimeSpan(8, 0, 0)
|
|
||||||
|
|
||||||
};
|
UserId = id,
|
||||||
|
LoginId = "SallyJones615",
|
||||||
|
FirstName = "Sally",
|
||||||
|
LastName = "Jones",
|
||||||
|
Email = "sally@jones.com",
|
||||||
|
Password = "password123",
|
||||||
|
Phone = "555-1234",
|
||||||
|
PhoneType = "Mobile",
|
||||||
|
IsFullTime = true,
|
||||||
|
IsEnrolledIn401k = false,
|
||||||
|
IsEnrolledInFlexTime = false,
|
||||||
|
IsEnrolledInHealthCare = true,
|
||||||
|
IsEnrolledInHSA = false,
|
||||||
|
IsActive = true,
|
||||||
|
BirthDate = Convert.ToDateTime("1975-11-04"),
|
||||||
|
StartTime = new TimeSpan(8, 0, 0)
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -65,9 +105,19 @@ public class UserViewModel : ViewModelBase
|
|||||||
|
|
||||||
return UserObject;
|
return UserObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
#region GetPhoneTypesMethod
|
||||||
|
public ObservableCollection<string> GetPhoneTypes()
|
||||||
|
{
|
||||||
|
if (_PhoneTypesList != null)
|
||||||
|
{
|
||||||
|
var list = _PhoneTypeRepository.Get();
|
||||||
|
PhoneTypesList = new ObservableCollection<string>(list.Select(row => row.TypeDescription));
|
||||||
|
}
|
||||||
|
|
||||||
|
return PhoneTypesList;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Save Method
|
#region Save Method
|
||||||
public virtual bool Save()
|
public virtual bool Save()
|
||||||
|
|||||||
10
Common.Library/Interfaces/IRepository.cs
Normal file
10
Common.Library/Interfaces/IRepository.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Common.Library;
|
||||||
|
|
||||||
|
public interface IRepository<TEntity>
|
||||||
|
{
|
||||||
|
ObservableCollection<TEntity> Get();
|
||||||
|
TEntity? Get(int id);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user