コード例 #1
0
ファイル: App.cs プロジェクト: bensport0007/CashFlowManager
        public void Start()
        {
            using (_session)
            {
                using (var transaction = _session.BeginTransaction())
                {
                    var transactionList = _transactionQueryHelper.GetAll();

                    //var transactionsList = _session.CreateCriteria<Transaction>().List<Transaction>().ToList();

                    var donator = _donatorQueryHelper.GetAllThatFitExpression(x => x.Number == 1).FirstOrDefault();

                    //var donator = _session.CreateCriteria<Donator>().List<Donator>().Where(x => x.Number == 1).FirstOrDefault();
                    var post = _session.CreateCriteria <Post>().List <Post>().FirstOrDefault();

                    //if (donator == null)
                    //{
                    //    var donator1 = new Donator {Number = 1, FirstName = "toto", LastName="pipo"};
                    //    _session.SaveOrUpdate(donator1);
                    //    donator = _session.CreateCriteria<Donator>().List<Donator>().FirstOrDefault(x => x.Id == 1);
                    //}

                    if (post == null)
                    {
                        var post1 = new Post {
                            Number = 12, Description = "Description du poste"
                        };
                        _session.SaveOrUpdate(post1);
                        post = _session.CreateCriteria <Post>().List <Post>().FirstOrDefault(x => x.Number == 12);
                    }

                    var inTransaction = new Transaction()
                    {
                        amount        = 123.12,
                        date          = DateTime.Now,
                        depositMethod = DepositMethod.Cash,
                        donator       = donator,
                        type          = TransactionType.Inflow,
                        post          = post
                    };

                    _session.SaveOrUpdate(inTransaction);
                    transaction.Commit();
                }
                Console.Read();
            }
        }
コード例 #2
0
 public IList <Donator> GetAllDonators()
 {
     return(_donatorQuerier.GetAll());
 }
コード例 #3
0
 public IList <Transaction> GetAllTransactions()
 {
     return(_transactionQuerier.GetAll());
 }
コード例 #4
0
 public IList <Post> GetAllPosts()
 {
     return(_postQuerier.GetAll());
 }