Ejemplo n.º 1
0
 private void When(BuildBindingsAdded @event)
 {
     foreach ((BuildsBinding binding, Guid[] builds) in @event.BindingToBuilds)
     {
         BindingToBuilds.Add(binding, builds.ToList());
     }
 }
Ejemplo n.º 2
0
 private void When(BuildBindingsRemoved @event)
 {
     foreach ((BuildsBinding binding, Guid[] _) in @event.BindingsToBuilds)
     {
         BindingToBuilds.Remove(binding);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Удаляет привязки.
        /// </summary>
        /// <param name="buildsBinding">Привязка к билдам для удаления.</param>
        /// <param name="actionUserId">Идентификатор пользователя, кто добавил привязки.</param>
        public void RemoveBuildBinding(IEnumerable <BuildsBinding> buildsBinding, string actionUserId)
        {
            var bindingsToRemove =
                BindingToBuilds
                .Where(x => buildsBinding.Contains(x.Key))
                .ToDictionary(x => x.Key, x => x.Value.ToArray());

            if (bindingsToRemove.IsEmpty())
            {
                return;
            }

            Apply(new BuildBindingsRemoved(bindingsToRemove, CreateMetadata(userId: actionUserId)));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Удаляет сборки из привязки.
        /// </summary>
        /// <param name="buildBinding">Привязка к сборкам.</param>
        /// <param name="buildIds">Идентификаторы сборок.</param>
        public void RemoveBuildsFromBinding(BuildsBinding buildBinding, Guid[] buildIds)
        {
            if (!BindingToBuilds.ContainsKey(buildBinding))
            {
                return;
            }

            var buildsToRemove = buildIds.Distinct().Intersect(BindingToBuilds[buildBinding]);

            if (buildsToRemove.IsEmpty())
            {
                return;
            }

            Apply(new BuildFromBuildsBindingRemoved(buildBinding, buildsToRemove.ToArray(), CreateMetadata()));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Удаляет новые сборки в привязку.
        /// </summary>
        /// <param name="buildBinding">Привязка к сборкам.</param>
        /// <param name="buildIds">Идентификаторы новых сборок.</param>
        public void AddBuildsToBinding(BuildsBinding buildBinding, Guid[] buildIds)
        {
            if (!BindingToBuilds.ContainsKey(buildBinding))
            {
                return;
            }

            var newBuildIds = buildIds.Distinct().Except(BindingToBuilds[buildBinding]);

            if (newBuildIds.IsEmpty())
            {
                return;
            }

            Apply(new BuildsToBuildsBindingAdded(buildBinding, newBuildIds.ToArray(), CreateMetadata()));
        }