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
/// <summary> | |
/// Load your modules or register your services here! | |
/// </summary> | |
/// <param name="kernel">The kernel.</param> | |
private static void RegisterServices(IKernel kernel) | |
{ | |
kernel.Bind<MyDBContext>() | |
.To<MyDBContext>() | |
.InRequestScope() |
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
public class SellProductCommand : ICommand | |
{ | |
public int ProductId { get; set; } | |
public int CustomerId { get; set; } | |
public string SellerComment { 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
public class SelectProductCommandHandler : ICommandHandler<SellProductCommand> | |
{ | |
private readonly DbContext _dbcontext; | |
public SelectProductCommandHandler(DbContext dbcontext) | |
{ | |
_dbcontext = dbcontext; | |
} | |
public void Execute(SellProductCommand command) |
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
public class Product | |
{ | |
public string Name { get; set; } | |
public int Id { get; set; } | |
public decimal Price { get; set; } | |
} | |
public class Order | |
{ | |
public int Id { 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
public class Program | |
{ | |
public static void Main(params object[] para) | |
{ | |
//ninject bootstrapping | |
var standardKernel = new StandardKernel(); | |
standardKernel.Bind<DbContext>().To<DbContext>(); | |
standardKernel.Bind<MessageProcessor>().To<MessageProcessor>(); | |
MessageProcessor messageProcessor = standardKernel.Get<MessageProcessor>(); | |
//link the commands with their handlers, and the events with their observers |
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
public class CustomerController : Controller | |
{ | |
private MyDbContext _dbContext; | |
public ActionResult Index() | |
{ | |
return View(_dbContext.Customers.OrderBy(c => c.Name).ToList()); | |
} | |
} | |
public class MyDbContext : DbContext | |
{ |
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
public class CustomerController : Controller | |
{ | |
private IMyDbContext _dbContext; | |
public CustomerController(IMyDbContext dbContext) | |
{ | |
_dbContext = dbContext; | |
} | |
public ActionResult Index() |
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
public class FakeMyDbContext : IMyDbContext | |
{ | |
public FakeMyDbContext(IEnumerable<Customer> customers ) | |
{ | |
Customers = customers.AsQueryable(); | |
} | |
public IQueryable<Customer> Customers { 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
public class Record | |
{ | |
public DateTime Start; | |
public DateTime End; | |
public long Id; | |
public TimeSpan Duration => End - Start; | |
private static long[] _pows = Enumerable.Range(0, 8).Select(i => (long)Math.Pow(10, i)).ToArray(); | |
public Record(string line) | |
{ |
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
/** | |
* The security configuration. | |
* <P> | |
* @author Pangee. | |
* @version 1.0.0-SNAPSHOT | |
*/ | |
@Configuration | |
@EnableWebSecurity | |
@EnableRedisHttpSession | |
@EnableGlobalMethodSecurity(prePostEnabled = true) |
OlderNewer