public EntityEntity(EntitySales pos, EntityNumber Entity, EntitySystematicType Systematic, DateTime validFrom, DateTime?validTo = null, bool isTest = false)
        {
            Id = Guid.NewGuid();
            if (pos == null)
            {
                throw new ArgumentNullException(nameof(pos));
            }
            if (pos.Id == Guid.Empty)
            {
                throw new InvalidOperationException("Пустой идентификатор пункта продажи");
            }
            if (pos.Deal == null)
            {
                throw new InvalidOperationException("Пустая информация об агенте");
            }
            if (pos.Deal.Code == null)
            {
                throw new InvalidOperationException("Пустой код агента");
            }

            EntitySales = new EntityEntitySales(pos);

            Number     = Entity.NumberAsIs;
            Systematic = Systematic;
            ValidFrom  = validFrom;
            ValidTo    = validTo ?? DefaultDateTo;
            IsTest     = isTest;
            _Places    = new List <EntityPlace>();
            _SrnPools  = new List <SrnPool>();
        }
        public EntityEntity(EntityEntityDataAccessModel model)
        {
            Id         = model.Id;
            Systematic = model.SystematicType;
            Number     = model.Number;
            IsTest     = model.IsTest;
            Comment    = model.Comment;
            ValidFrom  = model.ValidFrom;
            ValidTo    = model.ValidTo;
            _Places    = model.Places?.Select(o => new EntityPlace(o)).ToList() ?? new List <EntityPlace>();
            _SrnPools  = model.SrnEntity?.SrnPools?.Select(t => new SrnPool(t)).ToList() ?? new List <SrnPool>();
            if (model.SrnEntity != null)
            {
                SrnGroup = new SrnGroup(model.SrnEntity);
            }


            if (model.EntityEntitySales != null)
            {
                EntitySales = new EntityEntitySales(model.EntityEntitySales);
            }
        }