Ejemplo n.º 1
0
        private async Task <DataSourceClassification> GetFilledDataSourceClassification(DataSourceClassification parseDataSourceClassification)
        {
            DataSourceClassification ds = null;

            if (!string.IsNullOrEmpty(parseDataSourceClassification.Name) && !string.IsNullOrEmpty(parseDataSourceClassification.Code))
            {
                ds = await _ctx.DataSourceClassifications.FirstOrDefaultAsync(dsc =>
                                                                              !dsc.IsDeleted && (dsc.Name == parseDataSourceClassification.Name || dsc.NameLanguage1 == parseDataSourceClassification.Name || dsc.NameLanguage2 == parseDataSourceClassification.Name) &&
                                                                              dsc.Code == parseDataSourceClassification.Code);
            }
            else if (!string.IsNullOrEmpty(parseDataSourceClassification.Name))
            {
                ds = await _ctx.DataSourceClassifications.FirstOrDefaultAsync(dsc =>
                                                                              !dsc.IsDeleted && (dsc.Name == parseDataSourceClassification.Name || dsc.NameLanguage1 == parseDataSourceClassification.Name || dsc.NameLanguage2 == parseDataSourceClassification.Name));
            }
            else if (!string.IsNullOrEmpty(parseDataSourceClassification.Code))
            {
                ds = await _ctx.DataSourceClassifications.FirstOrDefaultAsync(dsc =>
                                                                              !dsc.IsDeleted && dsc.Code == parseDataSourceClassification.Code);
            }

            if (ds == null)
            {
                throw new Exception($"Data source classification by `{parseDataSourceClassification.Name}` name and {parseDataSourceClassification.Code} code not found");
            }

            return(ds);
        }
Ejemplo n.º 2
0
        public static DataSourceClassification ParseDataSourceClassification(string prop, string value,
                                                                             DataSourceClassification prev)
        {
            var result = prev ?? new DataSourceClassification();

            switch (prop)
            {
            case nameof(DataSourceClassification.Name):
                result.Name = value;
                break;

            case nameof(DataSourceClassification.Code):
                result.Code = value;
                break;

            default: throw UnsupportedPropertyOf <DataSourceClassification>(prop);
            }
            return(result);
        }