Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pattersonc
committed
Dec 24, 2009
0 parents
commit 976be25
Showing
191 changed files
with
37,584 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
_ReSharper*/ | ||
ShowOff.Core/bin/ | ||
ShowOff.Core/obj/ | ||
ShowOff.Tests/bin/ | ||
ShowOff.Tests/obj/ | ||
ShowOff.IntegrationTests/bin/ | ||
ShowOff.IntegrationTests/obj/ | ||
ShowOff/bin/ | ||
ShowOff/obj/ | ||
TestResults/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TestRunConfiguration name="Local Test Run" id="fcc4ae37-3984-49d4-be1d-685e5440c0eb" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2006"> | ||
<Description>This is a default test run configuration for a local test run.</Description> | ||
<Deployment> | ||
<DeploymentItem filename="ShowOff.IntegrationTests\App.config" /> | ||
</Deployment> | ||
<TestTypeSpecific /> | ||
</TestRunConfiguration> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<connectionStrings> | ||
<add name="ShowOffConnectionString" connectionString="Data Source=.\sqlexpress;Initial Catalog=ShowOff;Integrated Security=True;"/> | ||
</connectionStrings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using FluentNHibernate.Mapping; | ||
using ShowOff.Core.Model; | ||
|
||
namespace ShowOff.Core.Data | ||
{ | ||
public class ItemMap : ClassMap<Item> | ||
{ | ||
//public virtual int ID { get; set; } | ||
//public virtual string Name { get; set; } | ||
//public virtual string Description { get; set; } | ||
//public virtual string Url { get; set; } | ||
//public virtual string CreatedDate { get; set; } | ||
//public virtual string ModifiedDate { get; set; } | ||
//public virtual int DisplayPriority { get; set; } | ||
//public virtual IList<ItemImage> Images { get; set; } | ||
//public virtual ItemImage CoverImage { get; set; } | ||
//public virtual ItemType Type { get; set; } | ||
public ItemMap() | ||
{ | ||
Id(x => x.ID); | ||
Map(x => x.Name).Unique().Not.Nullable(); | ||
Map(x => x.Description); | ||
Map(x => x.Url); | ||
Map(x => x.CreatedDate).Not.Nullable(); | ||
Map(x => x.ModifiedDate).Not.Nullable(); | ||
Map(x => x.DisplayPriority); | ||
HasMany(x => x.Images).KeyColumn("ItemID").Cascade.All(); | ||
References(x => x.CoverImage).Column("CoverImageID").Cascade.All().Nullable(); | ||
References(x => x.Type).Column("ItemTypeID").Cascade.All().Not.Nullable(); | ||
} | ||
} | ||
|
||
public class ItemImageMap : ClassMap<ItemImage> | ||
{ | ||
//public virtual int ID { get; set; } | ||
//public virtual string Filename { get; set; } | ||
//public virtual string ThumbFilename { get; set; } | ||
public ItemImageMap() | ||
{ | ||
Id(x => x.ID); | ||
Map(x => x.Filename).Not.Nullable(); | ||
Map(x => x.ThumbFilename).Not.Nullable(); | ||
References(x => x.ItemID).Column("ItemID"); | ||
} | ||
} | ||
|
||
public class ItemTypeMap : ClassMap<ItemType> | ||
{ | ||
//public virtual int ID { get; set; } | ||
//public virtual string Name { get; set; } | ||
//public virtual string DisplayName { get; set; } | ||
public ItemTypeMap() | ||
{ | ||
Id(x => x.ID).GeneratedBy.Assigned(); | ||
Map(x => x.Name).Not.Nullable(); | ||
Map(x => x.DisplayName).Not.Nullable(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Configuration; | ||
using System.Reflection; | ||
using FluentNHibernate.Cfg; | ||
using FluentNHibernate.Cfg.Db; | ||
using NHibernate; | ||
using NHibernate.Tool.hbm2ddl; | ||
using Configuration=NHibernate.Cfg.Configuration; | ||
|
||
namespace ShowOff.Core.Data | ||
{ | ||
public static class SessionFactoryFactory | ||
{ | ||
private static Configuration _configuration; | ||
private static ISessionFactory _sessionFactory; | ||
|
||
private static string ConnectionString | ||
{ | ||
get { return ConfigurationManager.ConnectionStrings["ShowOffConnectionString"].ConnectionString; } | ||
} | ||
|
||
private static Configuration Configuration | ||
{ | ||
get | ||
{ | ||
if(_configuration == null) | ||
_configuration = Fluently.Configure() | ||
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(ConnectionString)) | ||
.Mappings(x => x.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())).BuildConfiguration(); | ||
|
||
return _configuration; | ||
} | ||
} | ||
|
||
public static ISessionFactory GetSessionFactory() | ||
{ | ||
if(_sessionFactory == null) | ||
_sessionFactory = Configuration.BuildSessionFactory(); | ||
|
||
return _sessionFactory; | ||
} | ||
|
||
public static void DropSchema() | ||
{ | ||
|
||
new SchemaExport(Configuration).Drop(false, true); | ||
} | ||
|
||
public static void CreateSchema() | ||
{ | ||
new SchemaExport(Configuration).Create(false, true); | ||
} | ||
|
||
public static void ExportMapping() | ||
{ | ||
////Fluently.Configure().Database(MsSqlConfiguration.MsSql2008.ConnectionString(ConnectionString)) | ||
//// .Mappings(x => x.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()).ExportTo("c:\temp\mappings")).BuildConfiguration(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using ShowOff.Core.Model; | ||
using ShowOff.Core.Repository; | ||
|
||
namespace ShowOff.Core.Data | ||
{ | ||
public static class SetupHelper | ||
{ | ||
public static void ResetDatabase() | ||
{ | ||
SessionFactoryFactory.DropSchema(); | ||
SessionFactoryFactory.CreateSchema(); | ||
} | ||
|
||
public static void AddDefaultData() | ||
{ | ||
var session = SessionFactoryFactory.GetSessionFactory().OpenSession(); | ||
|
||
// item types | ||
var websiteItemType = new ItemType() { ID = 1, Name = "Website", DisplayName = "Website" }; | ||
var logoItemType = new ItemType() { ID = 2, Name = "Logo", DisplayName = "Logo" }; | ||
var printItemType = new ItemType() { ID = 3, Name = "Print", DisplayName = "Print" }; | ||
var apparelItemType = new ItemType() { ID = 4, Name = "Apparel", DisplayName = "Apparel" }; | ||
|
||
session.SaveOrUpdate(websiteItemType); | ||
session.SaveOrUpdate(logoItemType); | ||
session.SaveOrUpdate(printItemType); | ||
session.SaveOrUpdate(apparelItemType); | ||
|
||
for (int j = 0; j < 10; j++) | ||
{ | ||
// item images | ||
var itemImageRepo = new ItemImageRepository(); | ||
|
||
var fileNames = new List<string>() | ||
{ | ||
"test1.jpg", | ||
"test2.jpg", | ||
"test3.jpg", | ||
"test4.jpg", | ||
"test5.jpg" | ||
}; | ||
|
||
|
||
var images = | ||
fileNames.Select( | ||
p => | ||
new ItemImage() | ||
{ | ||
Filename = p, | ||
ThumbFilename = Path.GetFileNameWithoutExtension(p) + "_thumb" + Path.GetExtension(p) | ||
}). | ||
ToList(); | ||
|
||
var item = new Item() | ||
{ | ||
Name = "ShowOff Item " + j, | ||
Description = "Show me off to the world.", | ||
Url = "http://www.showoffgallery.com", | ||
CreatedDate = DateTime.Now, | ||
ModifiedDate = DateTime.Now, | ||
Type = websiteItemType, | ||
Images = images, | ||
CoverImage = images[new Random().Next(0, 4)], | ||
DisplayPriority = 0 | ||
}; | ||
|
||
session.SaveOrUpdate(item); | ||
session.Flush(); | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace ShowOff.Core.Model | ||
{ | ||
public class Item | ||
{ | ||
public virtual int ID { get; set; } | ||
[Required] | ||
public virtual string Name { get; set; } | ||
[Required] | ||
public virtual string Description { get; set; } | ||
[Required] | ||
public virtual string Url { get; set; } | ||
|
||
public virtual DateTime CreatedDate { get; set; } | ||
public virtual DateTime ModifiedDate { get; set; } | ||
public virtual int DisplayPriority { get; set; } | ||
public virtual IList<ItemImage> Images { get; set; } | ||
public virtual ItemImage CoverImage { get; set; } | ||
public virtual ItemType Type { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace ShowOff.Core.Model | ||
{ | ||
public class ItemImage | ||
{ | ||
public virtual int ID { get; set;} | ||
public virtual string Filename { get; set;} | ||
public virtual string ThumbFilename { get; set; } | ||
public virtual Item ItemID { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace ShowOff.Core.Model | ||
{ | ||
public class ItemType | ||
{ | ||
public virtual int ID { get; set; } | ||
public virtual string Name { get; set; } | ||
public virtual string DisplayName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Security; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("ShowOff.Core")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Microsoft")] | ||
[assembly: AssemblyProduct("ShowOff.Core")] | ||
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: AllowPartiallyTrustedCallers] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("4d16ae0a-61f5-41de-8ec4-5a721a928732")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace ShowOff.Core.Repository | ||
{ | ||
public interface IRepository<T> | ||
{ | ||
void Save(); | ||
IList<T> GetAll(); | ||
T GetById(int id); | ||
void Add(T itemToAdd); | ||
void Add(IList<T> itemsToAdd); | ||
void Delete(T itemToDelete); | ||
void Delete(IList<T> itemsToDelete); | ||
} | ||
} |
Oops, something went wrong.