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(); } }
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; } }