Skip to content

Instantly share code, notes, and snippets.

View kmckelvin's full-sized avatar

Kevin McKelvin kmckelvin

View GitHub Profile
public bool Validate(XmlSchema schema, string filePath)
{
bool isValid = true;
XmlReaderSettings settings = new XmlReaderSettings();
try
{
settings.Schemas.Add(schema);
settings.ValidationType = ValidationType.Schema;
namespace MvcMusicStore.Models
{
public interface IMusicStoreContext
{
ISession Session { get; }
IQueryable<Album> Albums { get; }
IQueryable<Artist> Artists { get; }
IQueryable<Cart> Carts { get; }
IQueryable<Genre> Genres { get; }
IQueryable<Order> Orders { get; }
public class Album
{
public virtual int AlbumId { get; set;}
public virtual Genre Genre { get; set;}
public virtual Artist Artist { get; set; }
public virtual string Title { get; set; }
public virtual decimal Price { get; set; }
public virtual string AlbumArtUrl { get; set; }
}
public int CreateOrder(Order order)
{
using (var tx = storeDB.Session.BeginTransaction())
{
var cartItems = GetCartItems();
//Iterate the items in the cart, adding Order Details for each
foreach (var cartItem in cartItems)
{
var orderDetail = new OrderDetail
private static ISessionFactory SessionFactory = CreateSessionFactory();
private static ISessionFactory CreateSessionFactory()
{
var config = new Configuration();
config.DataBaseIntegration(
db =>
{
db.ConnectionStringName = "MusicStoreConnection",
public class MusicStoreContext : IMusicStoreContext
{
private readonly ISession _currentSession;
public MusicStoreContext(ISession currentSession)
{
_currentSession = currentSession;
}
public ISession Session
public static IMusicStoreContext GetCurrentRequestContext()
{
// get the ISession bound to the current request
var currentSession = SessionFactory.GetCurrentSession();
// build a context object to wrap it
var context = new MusicStoreContext(currentSession);
return context;
}
public class MusicStoreNinjectModule : NinjectModule
{
public override void Load()
{
Bind<AccountController>().ToSelf();
Bind<CheckoutController>().ToSelf();
Bind<HomeController>().ToSelf();
Bind<ShoppingCartController>().ToSelf();
Bind<StoreController>().ToSelf();
Bind<StoreManagerController>().ToSelf();
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Mvc Music Store" namespace="MvcMusicStore.Models">
<class name="Album">
<id name="AlbumId">
<generator class="identity" />
</id>
<many-to-one name="Genre" column="GenreId" />
<many-to-one name="Artist" column="ArtistId" />
<property name="Title" />
<property name="Price" />
@kmckelvin
kmckelvin / gist:1871125
Created February 20, 2012 20:12 — forked from jeriko/gist:1865932
KICKSTART v1
class AppBuilder < Rails::AppBuilder
include Thor::Actions
include Thor::Shell
# Express app templating for Rails
# ------------------------------------
# USAGE:
# 1. Add gems to `gem_dependencies`
# 2. Methods listed in SCRIPTS will be run after bundling, so make sure they each have a declaration
# 3. run: `rails new app_name --builder=path/to/builder.rb` (URI's work here too)