Example #1
0
 private void bindServices()
 {
     Kernel.Bind <CaloriesContext>().ToMethod((context) =>
     {
         var factory = new CaloriesContextFactory();
         return(factory.CreateDbContext(null));
     });
     Kernel.Bind <IUnitOfWork>().To <UnitOfWork>().InScope(RequestScope);
 }
Example #2
0
        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);
        }