private bool TryUpdateMapping( string entityName, EntityWithETag<MdmId> entityWithETag, MappingUpdatedEvent updatedEvent) { var response = mappingService.UpdateMapping( entityName, updatedEvent.MappingId, updatedEvent.EntityId, entityWithETag); if (!response.IsValid) { this.eventAggregator.Publish( new ErrorEvent(response.Fault != null ? response.Fault.Message : "Unknown Error")); return false; } return true; }
private bool TryGetMapping( string entityName, MappingUpdatedEvent updatedEvent, out EntityWithETag<MdmId> mapping) { mapping = mappingService.GetMapping(entityName, updatedEvent.EntityId, updatedEvent.MappingId); if (mapping.Object == null) { this.eventAggregator.Publish(new ErrorEvent("Unable to retrieve original mapping")); return false; } return true; }
private static MdmId NewMapping(EntityWithETag<MdmId> entityWithETag, MappingUpdatedEvent updatedEvent) { return new MdmId { DefaultReverseInd = updatedEvent.IsDefault, IsMdmId = false, SourceSystemOriginated = updatedEvent.IsSourceSystemOriginated, StartDate = updatedEvent.StartDate, Identifier = updatedEvent.NewValue, EndDate = entityWithETag.Object.EndDate, SystemName = entityWithETag.Object.SystemName, }; }
private void MappingUpdated(MappingUpdatedEvent updatedEvent) { if (updatedEvent.Cancelled) { return; } EntityWithETag<MdmId> entityWithETag; if (!TryGetMapping("Person", updatedEvent, out entityWithETag)) { return; } if (entityWithETag.Object.EndDate <= updatedEvent.StartDate) { var message = string.Format( "The start date of the new mapping must be before {0}", entityWithETag.Object.EndDate); this.eventAggregator.Publish(new ErrorEvent(message)); return; } var newMapping = NewMapping(entityWithETag, updatedEvent); if (!TryCreateMapping("Person", newMapping, updatedEvent)) { return; } if (!TryGetMapping("Person", updatedEvent, out entityWithETag)) { return; } entityWithETag.Object.EndDate = updatedEvent.StartDate.AddSeconds(-1); if (!TryUpdateMapping("Person", entityWithETag, updatedEvent)) { return; } this.LoadPersonFromService(updatedEvent.EntityId, updatedEvent.StartDate, true); this.eventAggregator.Publish(new StatusEvent(Message.MappingUpdated)); }
private void HideUpdateMapping(MappingUpdatedEvent obj) { this.ShowUpdateMappingRegion = false; this.applicationCommands.CloseView(typeof(MappingUpdateView), RegionNames.MappingUpdateRegion); }