public ActionResult Create(CreateOrganisationViewModel vm) { PrepareViewModel(vm); var validator = new OrganisationCreationValidator(ModelState, currencyRepository, entityRepository, organisationRepository); if (validator.Validate(vm, SessionHelper.CurrentEntity)) { var param = new CreateOrganisationParameters() { Name = vm.OrganisationName, OwnerID = SessionHelper.CurrentEntity.EntityID, CountryID = vm.CountryID }; var org = organisationService.CreateOrganisation(param); Transaction adminTransaction, countryTransaction; prepareTransactions(vm, SessionHelper.CurrentEntity, org, org.Country, out adminTransaction, out countryTransaction); transactionService.MakeTransaction(adminTransaction); transactionService.MakeTransaction(countryTransaction); return(RedirectToHome()); } return(View(vm)); }
public Organisation CreateOrganisation(CreateOrganisationParameters param) { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, SociatisTransactionOptions.RepeatableRead)) { var entity = entityService.CreateEntity(param.Name, EntityTypeEnum.Organisation); var organisation = new Organisation() { Entity = entity, OwnerID = param.OwnerID, CountryID = param.CountryID }; organisationRepository.Add(organisation); organisationRepository.SaveChanges(); scope.Complete(); return(organisation); } }