Esempio n. 1
0
        private void ReconcilePreconditions(UseCase src, UseCase dest)
        {
            // delete any use cases that are no more
            var deletes = dest.Preconditions.Where(a => !src.Preconditions.Select(b => b.Id).Contains(a.Id)).Select(a => a.Id).ToList();
            foreach (var preconditionId in deletes)
            {
                var precondition = dest.Preconditions.Where(a => a.Id == preconditionId).FirstOrDefault();
                dest.Preconditions.Remove(precondition);
            }

            foreach (var precondition in src.Preconditions)
            {
                if (precondition.Id == 0)
                {
                    dest.AddPrecondition(precondition);
                }
                else
                {
                    var existingPrecondition = dest.Preconditions.Where(a => a.Id == precondition.Id).FirstOrDefault();

                    if (existingPrecondition != null)
                    {
                        existingPrecondition.Description = precondition.Description;
                    }
                }

            }
        }