public async Task <IEnumerable <MenuAuthority> > SaveAsync(IEnumerable <MenuAuthority> menus, CancellationToken token = default(CancellationToken)) { using (var scope = transactionScopeBuilder.Create()) { var result = new List <MenuAuthority>(); foreach (var menu in menus) { result.Add(await addMenuAuthorityQueryProcessor.SaveAsync(menu, token)); } scope.Complete(); return(result); } }
public async Task <Company> InitializeAsync(CompanySource source, CancellationToken token = default(CancellationToken)) { using (var scope = transactionScopeBuilder.Create()) { var company = await addCompanyQueryProcessor.SaveAsync(source.Company, token); var companyId = company.Id; if (source.Company.Id == 0) { source.Company.Id = company.Id; await InitializeMasterDataAsync(source, token); } if (source.SaveCompanyLogos.Any()) { foreach (var x in source.SaveCompanyLogos) { x.CompanyId = company.Id; await addCompanyLogoQueryProcessor.SaveAsync(x, token); } } if (source.DeleteCompanyLogos.Any()) { foreach (var x in source.DeleteCompanyLogos) { await deleteCompanyLogoQueryProcessor.DeleteAsync(companyId, x.LogoType, token); } } if (source.ApplicationControl != null) // これだけはnull(更新対象外)の場合がある。 { source.ApplicationControl.CompanyId = company.Id; await addApplicationControlQueryProcessor.AddAsync(source.ApplicationControl, token); } foreach (var x in source.MenuAuthorities) { x.CompanyId = company.Id; await addMenuAuthorityQueryProcessor.SaveAsync(x, token); } foreach (var x in source.FunctionAuthorities) { x.CompanyId = company.Id; await addFunctionAuthorityQueryProcessor.SaveAsync(x, token); } source.PasswordPolicy.CompanyId = company.Id; await addPasswordPolicyQueryProcessor.SaveAsync(source.PasswordPolicy, token); if (source.LoginUserLicense != null) { source.LoginUserLicense.CompanyId = company.Id; await loginUserLicenseQueryProcessor.SaveAsync(source.LoginUserLicense, token); } scope.Complete(); return(company); } }