Пример #1
0
        public void Update(SourceDto sourceDto, IValidator validator = null)
        {
            if (validator == null)
                validator = new Validator();

            if (!validator.ValidEntry()) throw new InvalidDataException(validator.GetErrors());

            if (sourceDto.SourceId == Guid.Empty)
            {
                Insert(sourceDto);
            }
            else
            {
                Edit(sourceDto);
            }
        }
Пример #2
0
        public ServiceSourceObject Search(SourceSearchTypes param, SourceSearchFilter sourceSearchFilter,DataShaping shaper, IValidator validator = null)
        {
            var sourcesDataTable = new ServiceSourceObject();

            if(validator== null)
                validator = new Validator();

            if (!_security.IsvalidSelect()) throw new SecurityException("Missing select permission");

            if (!validator.ValidEntry()) throw new InvalidDataException(validator.GetErrors());

            switch (param)
            {
                case SourceSearchTypes.Standard:
                    sourcesDataTable = _sourceDal.FillSourceTableByFilter(sourceSearchFilter, shaper).ToServiceSourceObject(shaper.Column, shaper.RecordPageSize, shaper.RecordStart, shaper.TotalRecords);
                    break;
                case SourceSearchTypes.Treesources:
                    sourcesDataTable = _sourceDal.FillTreeSources(sourceSearchFilter).ToServiceSourceObject(shaper.Column, shaper.RecordPageSize, shaper.RecordStart);
                    break;
                case SourceSearchTypes.Censussource:
                    sourcesDataTable.CensusSources = _sourceDal.Get1841CensuSources(!sourceSearchFilter.Sources.IsNullOrBelowMinSize() ? sourceSearchFilter.Sources.First() : Guid.Empty);
                    break;
                case SourceSearchTypes.SourceIds:
                    sourcesDataTable = _sourceDal.FillSourceTableBySourceIds(!sourceSearchFilter.Sources.IsNullOrBelowMinSize() ? sourceSearchFilter.Sources : new List<Guid>())
                        .ToServiceSourceObject(shaper.Column, shaper.RecordPageSize, shaper.RecordStart);
                    break;
            }

            return sourcesDataTable;
        }