private void Refresh() { using (var context = new MasterDataContext()) { var supplier = context.Suppliers.Where(s => s.Id == CurrentSupplier.Id) .Include(s => s.Contacts).FirstOrDefault(); if (supplier != null) { CurrentSupplier = supplier; } else { NotificationRequest.Raise( new Notification { Content = "供应商" + supplier.Name + "不存在。\n可能已删除,请重新查询。", Title = "提示" } ); CurrentSupplier = new Supplier { InternalType = "Supplier", Contacts = new ObservableCollection <Contact>(), }; IsExisting = false; } } }
/// <inheritdoc/> public async Task <DimensionStructure> GetByIdAsync( DimensionStructure dimensionStructure, CancellationToken cancellationToken = default) { try { Check.IsNotNull(dimensionStructure); await _masterDataValidators.DimensionStructureValidator.ValidateAsync(dimensionStructure, o => { o.IncludeRuleSets(DimensionStructureValidatorRulesets.GetById); o.ThrowOnFailures(); }, cancellationToken).ConfigureAwait(false); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { DimensionStructure result = await ctx.DimensionStructures .FirstOrDefaultAsync(w => w.Id == dimensionStructure.Id, cancellationToken) .ConfigureAwait(false); return(result); } } catch (Exception e) { string msg = $"{nameof(MasterDataDimensionBusinessLogic)}.{nameof(GetByIdAsync)} " + $"operation failed. For further info see inner exception."; throw new MasterDataBusinessLogicDimensionStructureDatabaseOperationException(msg, e); } }
/// <inheritdoc/> public async Task DeleteAsync( DimensionStructure tobeDeleted, CancellationToken cancellationToken = default) { try { Check.IsNotNull(tobeDeleted); await _masterDataValidators.DimensionStructureValidator.ValidateAsync(tobeDeleted, o => { o.IncludeRuleSets(DimensionStructureValidatorRulesets.Delete); o.ThrowOnFailures(); }, cancellationToken).ConfigureAwait(false); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { DimensionStructure res = await ctx.DimensionStructures .FirstOrDefaultAsync(w => w.Id == tobeDeleted.Id, cancellationToken).ConfigureAwait(false); if (res != null) { ctx.DimensionStructures.Remove(res); await ctx.SaveChangesAsync(cancellationToken).ConfigureAwait(false); } } } catch (Exception e) { string msg = $"{nameof(MasterDataDimensionStructureBusinessLogic)}." + $"{nameof(DeleteAsync)} operation failed. " + $"For further details see inner exception!"; throw new MasterDataBusinessLogicDimensionStructureDatabaseOperationException(msg, e); } }
/// <inheritdoc/> public async Task <SourceFormat> GetSourceFormatByIdWithAllDimensionStructuresAndNodesAsync( SourceFormat sourceFormat) { try { Check.IsNotNull(sourceFormat); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { SourceFormat result = await ctx.SourceFormats .AsNoTracking() .Include(i => i.DimensionStructureNodes) .ThenInclude <SourceFormat, DimensionStructureNode, DimensionStructure>(ii => ii.DimensionStructure) .FirstOrDefaultAsync(w => w.Id == sourceFormat.Id) .ConfigureAwait(false); return(result); } } catch (Exception e) { string msg = $"{nameof(MasterDataSourceFormatBusinessLogic)}." + $"{nameof(GetSourceFormatByIdWithAllDimensionStructuresAndNodesAsync)} " + $"operation failed. For further info see inner exception."; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg, e); } }
protected override void ConfigureWebHost(IWebHostBuilder builder) { string entityName = $"Data Source=master_data.{typeof(TTestedEntity).Name}.db"; builder.ConfigureServices(services => { ServiceDescriptor masterDataDescriptor = services.SingleOrDefault( d => d.ServiceType == typeof(DbContextOptions <MasterDataContext>)); if (masterDataDescriptor != null) { services.Remove(masterDataDescriptor); } services.AddDbContext <MasterDataContext>(options => { options.UseSqlite(entityName); }); ServiceProvider sp = services.BuildServiceProvider(); using (IServiceScope scope = sp.CreateScope()) { IServiceProvider scopedServices = scope.ServiceProvider; MasterDataContext db = scopedServices.GetRequiredService <MasterDataContext>(); ILogger <DiLibMasterDataWebApplicationFactory <TStartup, TTestedEntity> > logger = scopedServices .GetRequiredService <ILogger <DiLibMasterDataWebApplicationFactory <TStartup, TTestedEntity> > >(); db.Database.EnsureDeleted(); db.Database.EnsureCreated(); } }); }
/// <inheritdoc/> public async Task <DimensionStructureNode> CreateDimensionStructureNodeAsync( DimensionStructureNode node, CancellationToken cancellationToken = default) { using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { try { Check.IsNotNull(node); await _masterDataValidators.DimensionStructureNodeValidator.ValidateAsync(node, o => { o.IncludeRuleSets(SourceFormatValidatorRulesets.CreateDimensionStructureNode); o.ThrowOnFailures(); }, cancellationToken) .ConfigureAwait(false); await ctx.DimensionStructureNodes.AddAsync(node, cancellationToken).ConfigureAwait(false); await ctx.SaveChangesAsync(cancellationToken).ConfigureAwait(false); return(node); } catch (Exception e) { string msg = $"{nameof(MasterDataSourceFormatBusinessLogic)}." + $"${nameof(CreateDimensionStructureNodeAsync)} failed. " + $"For further info see inner exception."; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg); } } }
/// <inheritdoc/> public async Task <DimensionStructureNode> GetNodeAsync( long sourceFormatId, long dimensionStructureId, CancellationToken cancellationToken = default) { using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { try { Check.AreNotEqual(sourceFormatId, 0); Check.AreNotEqual(dimensionStructureId, 0); DimensionStructureNode node = await ctx.DimensionStructureNodes .AsNoTracking() .Where(w => w.SourceFormatId == sourceFormatId) .FirstOrDefaultAsync( ww => ww.DimensionStructureId == dimensionStructureId, cancellationToken) .ConfigureAwait(false); return(node); } catch (Exception e) { string msg = $"{nameof(MasterDataSourceFormatBusinessLogic)}." + $"{nameof(GetNodeAsync)} operation failed. " + $"For further info see inner exception."; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg, e); } } }
public async Task DeleteDimensionAsync(Dimension dimension) { try { Check.IsNotNull(dimension); await _masterDataValidators.DimensionValidator.ValidateAsync(dimension, o => { o.IncludeRuleSets(ValidatorRulesets.DeleteDimension); o.ThrowOnFailures(); }).ConfigureAwait(false); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { Dimension toBeDeleted = await ctx.Dimensions.FindAsync(dimension.Id) .ConfigureAwait(false); if (toBeDeleted == null) { string msg = $"There is no {nameof(Dimension)} " + $"with id: {dimension}."; throw new MasterDataBusinessLogicNoSuchDimensionEntity(msg); } ctx.Dimensions.Remove(toBeDeleted); await ctx.SaveChangesAsync().ConfigureAwait(false); } } catch (Exception e) { throw new MasterDataBusinessLogicDeleteDimensionAsyncOperationException(e.Message, e); } }
private void Detail() { var supplier = SuppliersView.CurrentItem as Supplier; using (var context = new MasterDataContext()) { var existingSupplier = context.Suppliers.Where(s => s.Id == supplier.Id) .Include(s => s.Contacts).FirstOrDefault(); if (existingSupplier != null) { var parameters = new NavigationParameters { { "supplier", existingSupplier } }; IRegionManager regionManager = ServiceLocator.Current.GetInstance <IRegionManager>(); regionManager.RequestNavigate(RegionNames.MAIN_REGION, "SupplierDetail", parameters); } else { NotificationRequest.Raise( new Notification { Content = "供应商 " + supplier.Name + " 不存在。\n可能已删除,请重新查询。", Title = "提示" } ); } } }
private async Task <DimensionStructureNode> GetActiveDimensionStructureNodeTreeAsync( DimensionStructureNode dimensionStructureNode, MasterDataContext ctx) { Check.IsNotNull(dimensionStructureNode); Check.IsNotNull(ctx); DimensionStructureNode node = await ctx.DimensionStructureNodes .AsNoTracking() .Include(i => i.ChildNodes) .Include(ii => ii.DimensionStructure) .Where(p => p.DimensionStructure.IsActive == 1) .FirstAsync(w => w.Id == dimensionStructureNode.Id) .ConfigureAwait(false); if (node.ChildNodes.Any()) { foreach (DimensionStructureNode childNode in node.ChildNodes) { DimensionStructureNode n = await GetDimensionStructureNodeTreeAsync( childNode, ctx) .ConfigureAwait(false); dimensionStructureNode.ChildNodes.Add(n); } } return(dimensionStructureNode); }
/// <inheritdoc/> public async Task DeleteAsync( SourceFormat sourceFormat, CancellationToken cancellationToken = default) { try { Check.IsNotNull(sourceFormat); await _masterDataValidators.SourceFormatValidator.ValidateAsync(sourceFormat, o => { o.IncludeRuleSets(SourceFormatValidatorRulesets.Delete); o.ThrowOnFailures(); }, cancellationToken).ConfigureAwait(false); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { SourceFormat result = await ctx.SourceFormats .Include(p => p.DimensionStructureNodes) .Include(pp => pp.SourceFormatDimensionStructureNode) .FirstOrDefaultAsync( w => w.Id == sourceFormat.Id, cancellationToken ) .ConfigureAwait(false); if (result is null) { string msg = $"There is no {nameof(SourceFormat)} with id: {sourceFormat.Id}"; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg); } if (result.DimensionStructureNodes.Any()) { foreach (DimensionStructureNode node in result.DimensionStructureNodes) { ctx.Entry(node).State = EntityState.Deleted; } await ctx.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); } if (result.SourceFormatDimensionStructureNode is not null) { ctx.Entry(result.SourceFormatDimensionStructureNode).State = EntityState.Deleted; await ctx.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); } ctx.Entry(result).State = EntityState.Deleted; await ctx.SaveChangesAsync(cancellationToken).ConfigureAwait(false); } } catch (Exception e) { string msg = $"{nameof(MasterDataSourceFormatBusinessLogic)}." + $"{nameof(DeleteAsync)} operation failed! " + "For further information see inner exception!"; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg, e); } }
/// <inheritdoc/> public async Task <SourceFormat> AddAsync( SourceFormat sourceFormat, CancellationToken cancellationToken = default) { using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { try { Check.IsNotNull(sourceFormat); await _masterDataValidators.SourceFormatValidator.ValidateAsync(sourceFormat, o => { o.IncludeRuleSets(SourceFormatValidatorRulesets.Add); o.ThrowOnFailures(); }, cancellationToken).ConfigureAwait(false); await ctx.SourceFormats .AddAsync(sourceFormat, cancellationToken) .ConfigureAwait(false); await ctx.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); return(sourceFormat); } catch (Exception e) { string msg = $"Operation failed: {nameof(AddAsync)}. " + $"For further details see inner exception."; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg, e); } } }
/// <inheritdoc/> public async Task <SourceFormat> GetSourceFormatByIdWithRootDimensionStructureNodeAsync( SourceFormat querySourceFormat) { try { Check.IsNotNull(querySourceFormat); Check.AreNotEqual(querySourceFormat.Id, 0); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { SourceFormat sourceFormat = await ctx.SourceFormats .Include(i => i.SourceFormatDimensionStructureNode) .ThenInclude(ii => ii.DimensionStructureNode) .AsNoTracking() .FirstAsync(p => p.Id == querySourceFormat.Id) .ConfigureAwait(false); return(sourceFormat); } } catch (Exception e) { string msg = $"{nameof(MasterDataDimensionBusinessLogic)}." + $"{nameof(GetSourceFormatByIdWithRootDimensionStructureNodeAsync)} operation failed. " + $"For further details see inner exception."; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg, e); } }
public async Task <Dimension> GetValuesOfADimensionAsync(long dimensionId) { try { string msg = $"{nameof(dimensionId)} is null"; Check.AreNotEqual(dimensionId, 0, msg); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { Dimension dimension = await ctx.Dimensions .Include(i => i.DimensionDimensionValues) .ThenInclude <Dimension, DimensionDimensionValue, Dimension>(ti => ti.Dimension) .Include(j => j.DimensionDimensionValues) .ThenInclude <Dimension, DimensionDimensionValue, DimensionValue>(ji => ji.DimensionValue) .FirstOrDefaultAsync(p => p.Id == dimensionId) .ConfigureAwait(false); return(dimension); } } catch (Exception e) { throw new MasterDataBusinessLogicGetDimensionValueAsyncOperationException(e.Message, e); } }
/// <inheritdoc/> public async Task <SourceFormat> GetByIdAsync( SourceFormat sourceFormat, CancellationToken cancellationToken = default) { Check.IsNotNull(sourceFormat); try { await _masterDataValidators.SourceFormatValidator.ValidateAsync(sourceFormat, o => { o.IncludeRuleSets(SourceFormatValidatorRulesets.GetById); o.ThrowOnFailures(); }, cancellationToken).ConfigureAwait(false); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { return(await ctx.SourceFormats .FirstOrDefaultAsync(w => w.Id == sourceFormat.Id, cancellationToken) .ConfigureAwait(false)); } } catch (Exception e) { string msg = $"{nameof(MasterDataSourceFormatBusinessLogic)}." + $"{nameof(GetByIdAsync)} operation failed! " + $"For further information see inner exception!"; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg, e); } }
public frmTinhTien(int HDID) { InitializeComponent(); MasterDataContext db = new MasterDataContext(); gridControl1.DataSource = db.CTHD_Select(HDID); }
public async Task <Dimension> AddDimensionAsync(Dimension dimension) { try { Check.IsNotNull(dimension); await _masterDataValidators.DimensionValidator.ValidateAsync(dimension, o => { o.IncludeRuleSets(ValidatorRulesets.AddNewDimension); o.ThrowOnFailures(); }).ConfigureAwait(false); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { await ctx.Dimensions.AddAsync(dimension) .ConfigureAwait(false); await ctx.SaveChangesAsync().ConfigureAwait(false); return(dimension); } } catch (Exception e) { throw new MasterDataBusinessLogicAddDimensionAsyncOperationException(e.Message, e); } }
/// <inheritdoc/> public async Task <SourceFormat> GetSourceFormatByIdWithActiveOnlyDimensionStructuresInTheTreeAsync( SourceFormat querySourceFormat) { try { Check.IsNotNull(querySourceFormat); SourceFormat result = await GetSourceFormatByIdWithRootDimensionStructureNodeAsync(querySourceFormat) .ConfigureAwait(false); if (result == null) { return(null); } using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { DimensionStructureNode tree = await GetActiveDimensionStructureNodeTreeAsync( result.SourceFormatDimensionStructureNode.DimensionStructureNode, ctx) .ConfigureAwait(false); result.SourceFormatDimensionStructureNode.DimensionStructureNode = tree; } return(result); } catch (Exception e) { string msg = $"{nameof(MasterDataSourceFormatBusinessLogic)}." + $"{nameof(GetSourceFormatByIdWithActiveOnlyDimensionStructuresInTheTreeAsync)} " + $"operation failed. For further info see inner exception."; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg, e); } }
private void Delete() { ConfirmationRequest.Raise(new Confirmation { Content = "删除供应商" + CurrentSupplier.Number + "?", Title = "确认" }, r => { if (r.Confirmed) { using (var context = new MasterDataContext()) { context.Suppliers.Remove(CurrentSupplier); context.SaveChanges(); } IsEdit = false; NotificationRequest.Raise(new Notification { Content = "已删除", Title = "提示" }); CurrentSupplier = new Supplier { InternalType = "Supplier", Contacts = new ObservableCollection <Contact>(), }; Title = "供应商新增"; } }); }
private void Delete() { var supplier = SuppliersView.CurrentItem as Supplier; ConfirmationRequest.Raise( new Confirmation { Content = "删除供应商" + supplier.Name + "?", Title = "确认", }, r => { if (r.Confirmed) { using (var context = new MasterDataContext()) { var existingSupplier = context.Suppliers.Where(s => s.Id == supplier.Id) .Include(s => s.Contacts).FirstOrDefault(); if (existingSupplier == null) { NotificationRequest.Raise( new Notification { Content = "供应商" + supplier.Name + "不存在。\n可能已删除,请重新查询。", Title = "提示" } ); return; } context.Remove(existingSupplier); context.SaveChanges(); } NotificationRequest.Raise( new Notification { Content = "已删除。", Title = "提示" } ); Suppliers.Remove(supplier); SuppliersView.Refresh(); TotalRecords -= 1; TotalPages = (int)Math.Ceiling(1.0 * TotalRecords / PageSize); if (TotalPages == 0) { PageIndex = 0; } else if (PageIndex > TotalPages) { PageIndex = TotalPages; SuppliersView = CollectionViewSource.GetDefaultView(Suppliers.Skip((PageIndex - 1) * PageSize).Take(PageSize)); } } } ); }
private void Save() { using (var context = new MasterDataContext()) { if (!Validate(context)) { return; } var existingSupplier = context.Suppliers .Include(s => s.Contacts) .FirstOrDefault(s => s.Id == CurrentSupplier.Id); if (existingSupplier == null) { context.Add(CurrentSupplier); } else { context.Entry(existingSupplier).CurrentValues.SetValues(CurrentSupplier); foreach (var contact in CurrentSupplier.Contacts) { var existingContact = existingSupplier.Contacts .FirstOrDefault(c => c.Id == contact.Id); if (existingContact == null) { existingSupplier.Contacts.Add(contact); } else { context.Entry(existingContact).CurrentValues.SetValues(contact); } } foreach (var contact in existingSupplier.Contacts) { if (!CurrentSupplier.Contacts.Any(c => c.Id == contact.Id)) { context.Remove(contact); } } } context.SaveChanges(); NotificationRequest.Raise(new Notification { Content = "保存成功", Title = "提示" }); IsEdit = true; } }
private async Task <DimensionValue> GetDimensionValueWithRelatedEntities( string dimensionValueValue, MasterDataContext ctx) { Check.IsNotNull(dimensionValueValue); Check.IsNotNull(ctx); DimensionValue res = await ctx.DimensionValues .Include(i => i.DimensionDimensionValues) .FirstOrDefaultAsync(p => p.Value == dimensionValueValue) .ConfigureAwait(false); return(res); }
public async Task <long> CountDimensionValuesAsync() { using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { try { return(await ctx.DimensionValues.LongCountAsync().ConfigureAwait(false)); } catch (Exception e) { throw new MasterDataBusinessLogicCountDimensionValuesAsyncOperationException(e.Message, e); } } }
public async Task <long> CountSourceFormatsAsync() { using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { try { return(await ctx.SourceFormats.LongCountAsync().ConfigureAwait(false)); } catch (Exception e) { throw new MasterDataBusinessLogicCountSourceFormatsAsync(); } } }
/// <inheritdoc/> public async Task <SourceFormat> UpdateAsync( SourceFormat sourceFormat, CancellationToken cancellationToken = default) { try { Check.IsNotNull(sourceFormat); await _masterDataValidators.SourceFormatValidator.ValidateAsync(sourceFormat, o => { o.IncludeProperties(SourceFormatValidatorRulesets.Update); o.ThrowOnFailures(); }, cancellationToken).ConfigureAwait(false); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { SourceFormat target = await ctx.SourceFormats .FirstOrDefaultAsync(w => w.Id == sourceFormat.Id, cancellationToken) .ConfigureAwait(false); if (target != null) { target.Name = sourceFormat.Name; target.Desc = sourceFormat.Desc; target.IsActive = sourceFormat.IsActive; ctx.Entry(target).State = EntityState.Modified; await ctx.SaveChangesAsync(cancellationToken).ConfigureAwait(false); return(await ctx.SourceFormats .AsNoTracking() .FirstOrDefaultAsync(w => w.Id == sourceFormat.Id, cancellationToken) .ConfigureAwait(false)); } string msg = $"There is no {nameof(SourceFormat)} entity in the system with " + $"id: {sourceFormat.Id}."; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg); } } catch (Exception e) { string msg = $"{nameof(MasterDataSourceFormatBusinessLogic)}." + $"{nameof(UpdateAsync)} operation failed! " + "For further information see inner exception!"; throw new MasterDataBusinessLogicSourceFormatDatabaseOperationException(msg, e); } }
/// <inheritdoc/> public async Task <int> GetActiveCountAsync() { try { using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { return(await ctx.DimensionStructures.CountAsync(p => p.IsActive == 1).ConfigureAwait(false)); } } catch (Exception e) { string msg = $"{nameof(MasterDataDimensionStructureBusinessLogic)}." + $"{nameof(GetActiveCountAsync)} operation failed. " + $"For further info see inner exception!"; throw new MasterDataBusinessLogicDimensionStructureDatabaseOperationException(msg, e); } }
public async Task <List <Dimension> > GetDimensionsAsync() { try { using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { return(await ctx.Dimensions .AsNoTracking() .ToListAsync() .ConfigureAwait(false)); } } catch (Exception e) { throw new MasterDataBusinessLogicGetActiveDimensionsAsyncOperationException(); } }
public async Task <List <DimensionStructure> > GetAllAsync(CancellationToken cancellationToken = default) { using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { try { return(await ctx.DimensionStructures.ToListAsync(cancellationToken) .ConfigureAwait(false)); } catch (Exception e) { string msg = $"{nameof(MasterDataDimensionStructureBusinessLogic)}." + $"{nameof(GetAllAsync)} operation failed! " + $"For further info see inner exception!"; throw new MasterDataBusinessLogicDimensionStructureDatabaseOperationException(msg, e); } } }
/// <inheritdoc/> public async Task <DimensionStructure> UpdateAsync( DimensionStructure dimensionStructure, CancellationToken cancellationToken = default) { try { Check.IsNotNull(dimensionStructure); await _masterDataValidators.DimensionStructureValidator.ValidateAsync(dimensionStructure, o => { o.IncludeRuleSets(DimensionStructureValidatorRulesets.Update); o.ThrowOnFailures(); }, cancellationToken).ConfigureAwait(false); using (MasterDataContext ctx = new MasterDataContext(_dbContextOptions)) { DimensionStructure toBeModified = await ctx.DimensionStructures .FirstOrDefaultAsync(w => w.Id == dimensionStructure.Id, cancellationToken) .ConfigureAwait(false); string msg = $"There is no {typeof(DimensionStructure)} " + $"entity with id: {dimensionStructure.Id}"; Check.IsNotNull(toBeModified, msg); toBeModified.Name = dimensionStructure.Name; toBeModified.Desc = dimensionStructure.Desc; toBeModified.IsActive = dimensionStructure.IsActive; ctx.Entry(toBeModified).State = EntityState.Modified; await ctx.SaveChangesAsync(cancellationToken).ConfigureAwait(false); return(toBeModified); } } catch (Exception e) { string msg = $"{nameof(MasterDataDimensionStructureBusinessLogic)}." + $"{nameof(UpdateAsync)} operation failed. " + $"For further information see inner exception."; throw new MasterDataBusinessLogicDimensionStructureDatabaseOperationException(msg, e); } }
// Validation private bool Validate(MasterDataContext context) { if (string.IsNullOrWhiteSpace(CurrentSupplier.Number)) { NotificationRequest.Raise(new Notification { Content = "供应商编码为空", Title = "提示" }); return(false); } if (!IsEdit && context.Partners.Where(s => s.Number == CurrentSupplier.Number).FirstOrDefault() != null) { NotificationRequest.Raise(new Notification { Content = "供应商编码已存在", Title = "提示" }); return(false); } return(true); }