public void Process(EntityEntry <ProductionArea> source, ProductionAreaChangedMessage destination) { destination.ProductionArea = new ProductionAreaTO { Id = source.Entity.Id , Name = source.Entity.Name , Status = source.Entity.Status , Restrictions = new List <string>() }; foreach (Restriction restriction in source.Entity.Restrictions) { destination.ProductionArea.Restrictions.Add(restriction.Name); } //destination.State = ProductionAreaChangedMessage.ProductionAreaState.Added; }
private async Task ProcessMessagesProductionAreaChangedAsync(Message message, CancellationToken token) { try { ProductionAreaChangedMessage productionAreaChanged = JsonConvert.DeserializeObject <ProductionAreaChangedMessage>(Encoding.UTF8.GetString(message.Body)); using (StoreContext context = new StoreContext()) { var _productionAreaRepository = new ProductionAreaRepository(context); await _productionAreaRepository.UpsertAsync(productionAreaChanged.ProductionArea.ToProductionAreas()); } await _subscriptionClientProductionAreaChanged.CompleteAsync(message.SystemProperties.LockToken); } catch (Exception) { throw; } }