private void bindServices() { Kernel.Bind <CaloriesContext>().ToMethod((context) => { var factory = new CaloriesContextFactory(); return(factory.CreateDbContext(null)); }); Kernel.Bind <IUnitOfWork>().To <UnitOfWork>().InScope(RequestScope); }
static void Main(string[] args) { var context = new CaloriesContextFactory().CreateDbContext(new string[0]); var unit = new UnitOfWork(context); var repo = unit.WeightRepository; string str = System.Console.ReadLine(); decimal weight = decimal.Parse(str); repo.Add(new Data.Weight() { Date = DateTime.Now, Value = weight }); var task = unit.SaveChangesAsync(); Task.WaitAll(task); }