Skip to content

Instantly share code, notes, and snippets.

@Suchiman
Forked from JasonUnger/BuildComponent.cs
Last active May 2, 2018 00:52
Show Gist options
  • Select an option

  • Save Suchiman/8e331cf8c5353a65fb23873cd5b2114f to your computer and use it in GitHub Desktop.

Select an option

Save Suchiman/8e331cf8c5353a65fb23873cd5b2114f to your computer and use it in GitHub Desktop.
using System;
using System.ComponentModel.DataAnnotations;
namespace WarehouseBuilder.Common.API
{
public class BuildComponent
{
public virtual long Id { get; set; }
public virtual Warehouse Warehouse { get; set; }
public virtual int Order { get; set; }
// User editable
public virtual String DisplayName { get; set; }
public virtual bool Enabled { get; set; }
public virtual String BatchFile { get; set; }
public virtual int MaxBuildMinutes { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace WarehouseBuilder.Common.API
{
public class Customer
{
public virtual long Id { get; set; }
public virtual int Order { get; set; }
public virtual ICollection<Warehouse> Warehouses { get; set; }
// User editable
public virtual Customer Dependancy { get; set; }
public virtual DateTime? RunAfter { get; set; }
public virtual String DisplayName { get; set; }
public virtual bool Enabled { get; set; }
public virtual int Number { get; set; }
public virtual String BaseDirectory { get; set; }
}
}
using System.Data.Entity;
using WarehouseBuilder.Common.API;
namespace WarehouseBuilder.Common
{
public class DatabaseContext : DbContext
{
public DatabaseContext() : base("Default")
{
}
public DbSet<Customer> Customers { get; set; }
public DbSet<Warehouse> Warehouses { get; set; }
public DbSet<BuildComponent> BuildComponents { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Warehouse>().HasRequired(g => g.Customer).WithMany(g => g.Warehouses);
modelBuilder.Entity<BuildComponent>().HasOptional(w => w.Warehouse).WithMany(w => w.Components);
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace WarehouseBuilder.Common.API
{
public class Warehouse
{
public virtual long Id { get; set; }
public virtual Customer Customer { get; set; }
public virtual ICollection<BuildComponent> Components { get; set; }
public virtual int Order { get; set; }
// User editable
public virtual String DisplayName { get; set; }
public virtual bool Enabled { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment