/// <summary>
 /// Добавить анкету
 /// </summary>
 /// <param name="questionary">анкета</param>
 public void Add(Questionary questionary)
 {
     Handle(() =>
     {
         Validate(questionary);
         Dao.Add(questionary);
     });
 }
 /// <summary>
 /// Изменить анкету
 /// </summary>
 /// <param name="questionary">анкета</param>
 public void Change(Questionary questionary)
 {
     Handle(() =>
     {
         Validate(questionary);
         Dao.Change(questionary);
     });
 }
 /// <summary>
 /// Изменить анкету
 /// </summary>
 /// <param name="questionary">анкета</param>
 public void Change(Questionary questionary)
 {
     if (string.IsNullOrWhiteSpace(questionary.Id))
     {
         throw new DaoException(ErrorCode.CanNotChangeUnsavedObject, typeof(Questionary).Name);
     }
     Handle(repository => repository.Change(questionary));
 }
 protected void ChangeQuestionary(Questionary questionary)
 {
     if (!testQuestionaries.ContainsKey(questionary.Id))
     {
         throw new InternalException("нет анкеты для обновления");
     }
     testQuestionaries[questionary.Id] = questionary;
 }
 private void Validate(Questionary questionary)
 {
     QuestionaryValidator validator = new QuestionaryValidator();
     ValidateResult validateResult = validator.Validate(questionary);
     if (!validateResult.IsValid)
     {
         throw new ValidationException(ErrorCode.ValidationError, validateResult.ToString());
     }
 }
 /// <summary>
 /// Добавить анкету в репозиторий
 /// </summary>
 /// <param name="questionary">анкета</param>
 public void Add(Questionary questionary)
 {
     Synchronize(() =>
     {
         questionary.Id = GetUniqueId(questionary.Person);
         repository.Add(questionary.Id, questionary);
         Save(ObjectUtils.Serialize(repository));
     });
 }
 /// <summary>
 /// Выполнить проверки валидности заполнения анкеты
 /// </summary>
 /// <param name="questionary">анкета</param>
 public ValidateResult Validate(Questionary questionary)
 {
     ValidateResult result = new ValidateResult();
     //todo тут проверки валидации анкеты с заполнением ValidateResult, например:
     if (string.IsNullOrWhiteSpace(questionary.Person.FirstName))
     {
         result.Add("Не заполнено поле 'Имя'");
     }
     return result;
 }
 /// <summary>
 /// Добавить анкету
 /// </summary>
 /// <param name="questionary">анкета</param>
 public void Add(Questionary questionary)
 {
     Handle(repository =>
     {
         if (repository.Contains(questionary))
         {
             throw new DaoException(ErrorCode.ObjectNotUnique, questionary.Person.ToString());
         }
         repository.Add(questionary);
     }
     );
 }
 /// <summary>
 /// Изменить анкету в репозитории
 /// </summary>
 /// <param name="questionary">анкета</param>
 public void Change(Questionary questionary)
 {
     Synchronize(() =>
     {
         if (string.IsNullOrWhiteSpace(questionary.Id) || !repository.ContainsKey(questionary.Id))
         {
             throw new DaoException(ErrorCode.ObjectNotFound, typeof(Questionary).Name, questionary.Id);
         }
         string id = GetUniqueId(questionary.Person);
         if (questionary.Id != id) //изменилась ключевая информация
         {
             repository.Remove(questionary.Id);
             repository.Add(questionary.Id = id, questionary);
         }
         else
         {
             repository[id] = questionary;
         }
         Save(ObjectUtils.Serialize(repository));
     });
 }
 protected bool Contains(Questionary questionary)
 {
     return !string.IsNullOrEmpty(questionary.Id) && testQuestionaries.ContainsKey(questionary.Id);
 }
 protected void AddQuestionary(Questionary questionary)
 {
     questionary.Id = Guid.NewGuid().ToString();
     testQuestionaries.Add(questionary.Id, questionary);
 }
 /// <summary>
 /// Изменить анкету
 /// </summary>
 /// <param name="questionary">анкета</param>
 public void Change(Questionary questionary)
 {
     handler.Change(questionary);
 }
 /// <summary>
 /// Добавить анкету
 /// </summary>
 /// <param name="questionary">анкета</param>
 public void Add(Questionary questionary)
 {
     handler.Add(questionary);
 }
 /// <summary>
 /// Проверить наличие анкеты в репозитории
 /// </summary>
 /// <param name="questionary">анкета</param>
 /// <returns>факт наличия анкеты в репозирории</returns>
 public bool Contains(Questionary questionary)
 {
     bool result = false;
     Synchronize(() => result = repository.ContainsKey(GetUniqueId(questionary.Person)));
     return result;
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Questionary = QuestionaryFactory.Create();
 }
 public void Add(Questionary questionary)
 {
     Questionaries.Add(questionary);
 }