private void CreateOrEditDataTypeParameterValues(Member member, string parameters) { if (member.PropertyDataTypeId == null || string.IsNullOrEmpty(parameters)) { return; } IDataTypeParameterRepository dataTypeParameterRepository = this.Storage.GetRepository <IDataTypeParameterRepository>(); IDataTypeParameterValueRepository dataTypeParameterValueRepository = this.Storage.GetRepository <IDataTypeParameterValueRepository>(); foreach (KeyValuePair <string, string> valueByCode in ParametersParser.Parse(parameters)) { DataTypeParameter dataTypeParameter = dataTypeParameterRepository.WithDataTypeIdAndCode((int)member.PropertyDataTypeId, valueByCode.Key); DataTypeParameterValue dataTypeParameterValue = dataTypeParameterValueRepository.WithDataTypeParameterIdAndMemberId(dataTypeParameter.Id, member.Id); if (dataTypeParameterValue == null) { dataTypeParameterValue = new DataTypeParameterValue(); dataTypeParameterValue.DataTypeParameterId = dataTypeParameter.Id; dataTypeParameterValue.MemberId = member.Id; dataTypeParameterValue.Value = valueByCode.Value; dataTypeParameterValueRepository.Create(dataTypeParameterValue); } else { dataTypeParameterValue.Value = valueByCode.Value; dataTypeParameterValueRepository.Edit(dataTypeParameterValue); } } this.Storage.Save(); }
public IndexViewModel Create(int dataTypeId, string orderBy, string direction, int skip, int take, string filter) { IDataTypeParameterRepository dataTypeParameterRepository = this.RequestHandler.Storage.GetRepository <IDataTypeParameterRepository>(); return(new IndexViewModel() { DataTypeId = dataTypeId, Grid = new GridViewModelFactory(this.RequestHandler).Create( orderBy, direction, skip, take, dataTypeParameterRepository.CountByDataTypeId(dataTypeId, filter), new[] { new GridColumnViewModelFactory(this.RequestHandler).Create("Name", "Name"), new GridColumnViewModelFactory(this.RequestHandler).CreateEmpty() }, dataTypeParameterRepository.FilteredByDataTypeIdRange(dataTypeId, orderBy, direction, skip, take, filter).Select(dtp => new DataTypeParameterViewModelFactory(this.RequestHandler).Create(dtp)), "_DataTypeParameter" ) }); }