예제 #1
0
        public void AddOrganization(Organization o, int farmerId)
        {
            using (var scope = new TransactionScope())
            {
                farmerVersionRepo.UpdateWhatWhere(new { EndDate = DateTime.Now }, new { farmerId, EndDate = DBNull.Value });

                o.FarmerVersionId = farmerVersionRepo.Insert(new FarmerVersion { FarmerId = farmerId, StartDate = DateTime.Now });
                organizationRepo.Insert(o);

                scope.Complete();
            }
        }
예제 #2
0
        public int CreateOrganization(Organization o)
        {
            using (var scope = new TransactionScope())
            {
                var farmerId = farmerRepo.Insert(new Farmer { FType = FarmerType.Organization });

                var v = new FarmerVersion
                            {
                                FarmerId = farmerId,
                                StartDate = DateTime.Now
                            };

                o.FarmerVersionId = farmerVersionRepo.Insert(v);

                organizationRepo.Insert(o);

                scope.Complete();
                return farmerId;
            }
        }