Exemplo n.º 1
0
        private async Task SetCatalogAsync(UserObj u)
        {
            var catalogDb = await this._reaer.Catalogs
                            .Qa()
                            .Where(c => c.Creator == u.UserId)
                            .OrderByDescending(c => c.Code)
                            .ToListAsync();

            u.Catalog = new CatalogData()
            {
                Grade   = new Dictionary <string, CatalogValue>(),
                Subject = new Dictionary <string, IList <CatalogValue> >()
            };

            foreach (var item in catalogDb)
            {
                var valueItem = new CatalogValue
                {
                    Code  = item.Code,
                    Count = item.Count,
                    Name  = item.Name
                };


                if (item.ParentCode == "")
                {
                    u.Catalog.Grade.TryAdd(item.Code, valueItem);
                    continue;
                }

                if (u.Catalog.Subject.TryGetValue(item.ParentCode, out IList <CatalogValue> value))
                {
                    if (value.Any(v => v.Code == item.Code) == false)
                    {
                        value.Add(valueItem);
                    }
                    continue;
                }
                u.Catalog.Subject[item.ParentCode] = new List <CatalogValue> {
                    valueItem
                };
            }

            //throw new NotImplementedException();
        }
Exemplo n.º 2
0
        private CatalogsJoinSample GetCatalogsJoinSample(CatalogValue category, CatalogValue recordType)
        {
            var faker = new Faker <CatalogsJoinSample>()
                        .Rules((f, e) =>
            {
                e.Category     = category;
                e.RecordType   = recordType;
                e.CategoryId   = category.CatalogValueId;
                e.RecordTypeId = recordType.CatalogValueId;
                e.Comments     = f.Random.Words(f.Random.Int(2, 25));
                e.JoinSampleId = CounterSingleton.Instance.CounterArray[6]++;
                e.CreatedDate  = DateTime.UtcNow;
                e.IsCommited   = true;
                e.IsEnabled    = true;
            });

            return(faker.Generate());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCatalogValue"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        public UPCatalogValue(CatalogValue value)
        {
            if (value == null)
            {
                return;
            }

            this.Code     = value.Code;
            this.Text     = value.Text;
            this.Sortinfo = value.SortInfo;
            this.Access   = value.Access;
            if (value.IsFixedValue)
            {
                return;
            }

            var varValue = (VariableCatalogValue)value;

            this.ExtKey = varValue.ExtKey;
            this.Tenant = varValue.GetTenantNo();
        }
Exemplo n.º 4
0
        private MultiSelectList GetMultiSelectList(MultiSelectSample multiSelectSample, CatalogValue catalogValue)
        {
            var faker = new Faker <MultiSelectList>()
                        .Rules((f, e) =>
            {
                e.CatalogValue        = catalogValue;
                e.CatalogValueId      = catalogValue.CatalogValueId;
                e.MultiSelectSample   = multiSelectSample;
                e.MultiSelectSampleId = multiSelectSample.MultiSelectSampleId;
                e.IsEnabled           = f.Random.Bool(0.9f);
            });

            return(faker.Generate());
        }
Exemplo n.º 5
0
        private HideEnableMultiselection GetHideEnableMultiselection(HideEnableSample hideEnableSample, CatalogValue catalogValue)
        {
            var faker = new Faker <HideEnableMultiselection>()
                        .Rules((f, e) =>
            {
                e.CatalogValue       = catalogValue;
                e.CatalogValueId     = catalogValue.CatalogValueId;
                e.HideEnableSample   = hideEnableSample;
                e.HideEnableSampleId = hideEnableSample.HideEnableSampleId;
                e.IsEnabled          = f.Random.Bool(0.9f);
            });

            return(faker.Generate());
        }