public IEnumerable <ConfigurationRowModel> CreateRows(int idConfiguration, int countRows)
        {
            var listRows = new List <ConfigurationRowModel>();

            for (int i = 0; i < countRows; i++)
            {
                var novaLinha = new ConfigurationRowModel
                {
                    ConfigurationId = idConfiguration,
                    Index           = i
                };

                listRows.Add(novaLinha);
            }

            return(listRows);
        }
예제 #2
0
        public void InsertRangeValuesDto(int idConfiguration, int idRow, IEnumerable <ConfigurationValueDto> configurationValuesDto)
        {
            var configurationValuesModel = _mapper.Map <IEnumerable <ConfigurationValueModel> >(configurationValuesDto);

            var configurationRowModel = _configurationRowRepository.GetById(idRow);

            if (configurationRowModel == null)
            {
                var lastRow   = _configurationRowRepository.GetRowsByConfiguration(idConfiguration).FirstOrDefault();
                var lastIndex = lastRow == null ? 0 : lastRow.Index;
                configurationRowModel = new ConfigurationRowModel()
                {
                    ConfigurationId = idConfiguration,
                    Index           = lastIndex++
                };
                _configurationRowRepository.Insert(configurationRowModel);
            }

            configurationValuesModel.ToList().ForEach(a => a.ConfigurationRowId = configurationRowModel.Id);

            _configurationValueRepository.InsertRange(configurationValuesModel);
        }