public void CopySummary(int enterpriseId, string title, int summaryId)
        {
            #region Pre-conditions
            if (title == null) { throw new ArgumentNullException("title"); }
            if (!_context.Summaries.Any(x => x.Id == summaryId && x.EnterpriseId == enterpriseId)) { throw new ArgumentException("Wrong summary id", summaryId.ToString(CultureInfo.InvariantCulture)); }
            #endregion

            Summary summaryTo = new Summary();
            summaryTo.Title = title;
            summaryTo.CreateDate = DateTime.Now;
            summaryTo.Published = false;
            summaryTo.EnterpriseId = enterpriseId;
            _context.Summaries.Add(summaryTo);

            Summary summaryFrom = _context.Summaries.First(x => x.Id == summaryId);
            IEnumerable<SummaryActivity> summaryActivities =
              _context.SummaryActivities.Where(x => x.SummaryId == summaryFrom.Id);
            foreach (SummaryActivity summaryActivity in summaryActivities)
            {
                _context.SummaryActivities.Add(new SummaryActivity { SummaryId = summaryTo.Id, ActivityId = summaryActivity.ActivityId });
            }
            IEnumerable<Person> people = _context.People.Where(x => x.SummaryId == summaryFrom.Id);
            foreach (var person in people)
            {
                if (person.DismissalYear != null)
                {
                    Person newPerson = new Person
                      {
                          BirthYear = person.BirthYear,
                          ActivityId = person.ActivityId,
                          DismissalYear = person.DismissalYear,
                          EducationLevelId = person.EducationLevelId,
                          Gender = person.Gender,
                          HiringYear = person.HiringYear,
                          Post = person.Post,
                          PostLevelId = person.PostLevelId,
                          StartPostYear = person.StartPostYear,
                          SummaryId = summaryTo.Id,
                          Title = person.Title,
                          WasQualificationIncrease = person.WasQualificationIncrease,
                          WasValidate = person.WasValidate,
                          YearSalary = person.YearSalary
                      };
                    _context.People.Add(newPerson);
                }
            }
            _context.SaveChanges();
        }
        public void CreateSummary(int enterpriseId, string title, List<int> activitiesIds)
        {
            #region Pre-conditions
            if (title == null) { throw new ArgumentNullException("title"); }
            if (activitiesIds == null) { throw new ArgumentNullException("activitiesIds"); }
            if (!_context.Enterprises.Any(x => x.Id == enterpriseId)) { throw new ArgumentException("Wrong enterprise id", enterpriseId.ToString(CultureInfo.InvariantCulture)); }
            #endregion

            Summary newSummary = new Summary();
            newSummary.CreateDate = DateTime.Now;
            newSummary.EnterpriseId = enterpriseId;
            newSummary.Published = false;
            newSummary.Title = title;
            _context.Summaries.Add(newSummary);
            foreach (int activity in activitiesIds)
            {
                _context.SummaryActivities.Add(new SummaryActivity { SummaryId = newSummary.Id, ActivityId = activity });
            }
            _context.SaveChanges();
        }