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

            // update the list of steps
            foreach (var step in src.UseCaseSteps)
            {
                // new step
                if (step.Id == 0)
                {
                    dest.AddStep(step);
                }
                // editing an existing step
                else
                {
                    var existingStep = dest.UseCaseSteps.Where(a => a.Id == step.Id).FirstOrDefault();

                    if (existingStep != null)
                    {
                        AutoMapper.Mapper.Map(step, existingStep);
                    }
                }
            }
        }