public int CreateLandOwner(LandOwner o) { using (var scope = new TransactionScope()) { var farmerId = farmerRepo.Insert(new Farmer { FType = FarmerType.LandOwner }); var v = new FarmerVersion { FarmerId = farmerId, StartDate = DateTime.Now }; o.FarmerVersionId = farmerVersionRepo.Insert(v); landOwnerRepo.Insert(o); scope.Complete(); return(farmerId); } }
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); } }