public async Task Create(string name, CategoryValue categoryValue)
        {
            var subcategory = Subcategory.Create(name, categoryValue);

            subcategoryRepository.AddSubcategory(subcategory);
            await unitOfWork.CompleteAsync();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the value to convert into an instance of <see cref="CategoryValue" />.</param>
 /// <returns>
 /// an instance of <see cref="CategoryValue" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         CategoryValue.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new CategoryValue
         {
             Description = sourceValue.Description,
             ApiVersion = sourceValue.ApiVersion,
             Value = sourceValue.Value,
         });
     }
     catch
     {
     }
     return(null);
 }
 /// <summary>
 /// Gets the services available for the specified server.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <returns>A collection of service names for the specified server.</returns>
 public IEnumerable <string> GetServerServices(string server)
 {
     using (EnterpriseTestContext context = DbConnect.EnterpriseTestContext())
     {
         CategoryValue serverCategory = context.CategoryValues.FirstOrDefault(n => n.Category == "ServerService" && n.Value == server);
         return(serverCategory?.Children.Select(n => n.Value).ToList() ?? Enumerable.Empty <string>());
     }
 }
Exemplo n.º 4
0
 private Subcategories Create(string name, CategoryValue category)
 {
     return(new Subcategories()
     {
         Id = Guid.NewGuid(),
         Name = name,
         Category = category
     });
 }
Exemplo n.º 5
0
        public CategoryTreeNode(CategoryValue val)
        {
            _categoryValue = val;

            Text = val.KeyName;
            //
            // Add a blank node to force the + sign.
            //
            Nodes.Add(new TreeNode());
        }
Exemplo n.º 6
0
        public async Task <Category> GetCategory(CategoryValue value)
        {
            var subcategories = await context
                                .Subcategories
                                .Where(x => x.Category == value)
                                .Select(x => new SubcategoryObject(x.Id, x.Name))
                                .ToListAsync();

            return(new Category(value, subcategories.ToArray()));
        }
Exemplo n.º 7
0
        private IList <CategoryWeight> GetWeightDataFromMorningstar(Category category, Security security)
        {
            if (category.Name.Equals("assetallocation", StringComparison.InvariantCultureIgnoreCase))
            {
                var assetAllocation = _scraper.GetAssetAllocation(TranslateSymbol(security));
                var values          = _categoryRepository.GetValues(category).ToList();
                var list            = new List <CategoryWeight>();

                if (!assetAllocation.Any())
                {
                    var value = values.SingleOrDefault(v => v.Name.Equals(NotApplicable));
                    if (value == null)
                    {
                        value = new CategoryValue {
                            Category = category, Name = NotApplicable
                        };
                        _categoryRepository.AddValues(category, new[] { value });
                    }
                    list.Add(new CategoryWeight {
                        Security = security, Weight = 100M, Value = value
                    });
                }
                else
                {
                    foreach (var kvpair in assetAllocation)
                    {
                        var categoryValueName = kvpair.Key;
                        var value             = values.SingleOrDefault(v => v.Name.Equals(categoryValueName));
                        if (value == null)
                        {
                            value = new CategoryValue {
                                Category = category, Name = categoryValueName
                            };
                            _categoryRepository.AddValues(category, new[] { value });
                        }
                        list.Add(new CategoryWeight {
                            Security = security, Weight = kvpair.Value, Value = value
                        });
                    }
                }

                _categoryRepository.AddWeights(category, security, list);
                return(list);
            }

            throw new CategoryNotSupportedException(string.Format("Category not supported: {0}", category.Name));
        }
        private Category GetCategory()
        {
            if (Category == null || !Category.Any())
            {
                return(null);
            }

            CategoryValue categoryValue = (CategoryValue)0;

            foreach (string categoryName in Category)
            {
                categoryValue |= (CategoryValue)Enum.Parse(typeof(CategoryValue), categoryName);
            }

            WriteDebug($"Converted category value: {categoryValue}");
            return(new Category(categoryValue));
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Initializes Category collection in database with default values.
        /// </summary>
        /// <author>Anna Krebs</author>
        /// <param name="categoryValue"></param>
        /// <returns></returns>
        private async Task InitCategoryCollection(CategoryValue categoryValue)
        {
            var categoryValueString = categoryValue.ToString();
            var sortOrder           = Convert.ToInt32(categoryValue);

            var categoryCollection = _mongoContext.Database.GetCollection <Category>(nameof(Category));
            var isDuplicate        =
                await MongoHelper <Category> .IsDuplicate(Constants.Name, categoryValueString, categoryCollection, null);

            if (!isDuplicate)
            {
                await categoryCollection.InsertOneAsync(
                    new Category { Name = categoryValueString, SortOrder = sortOrder });

                Log.Info($"Inserted category {categoryValue} into database.");
            }
        }
Exemplo n.º 10
0
        public IList <CategoryValue> SelectAll()
        {
            //var query = new DocumentsListQuery();
            //query.ShowFolders=true;

            //DocumentsFeed feed = Service.Query(query);
            //var res= new List<CategoryValue>();
            //foreach (var d in feed.Entries.Cast<DocumentEntry>().Where(e => e.IsFolder))
            //{

            //   res.Add(new CategoryValue
            //               {
            //                   Name = d.Title.Text,

            //               });
            //}
            //return res;


            RequestSettings settings = new RequestSettings("GoogleDocumentsSample", Service.Credentials);

            var req  = new DocumentsRequest(settings);
            var res  = new List <CategoryValue>();
            var feed = req.GetFolders();

            foreach (var d in feed.Entries)
            {
                var cat = new CategoryValue
                {
                    Name       = d.Title,
                    CategoryID = GetInternalId(d.ResourceId)
                };
                if (d.ParentFolders.Count > 0)
                {
                    cat.ParentCategoryID = GetInternalId(GetGlobaId(d.ParentFolders[0]));
                }
                res.Add(cat);
            }
            return(res);
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Initializes Effect collection in database with default values.
        /// </summary>
        /// <author>Anna Krebs</author>
        /// <param name="name"></param>
        /// <param name="categoryValue"></param>
        /// <returns></returns>
        private async Task InitEffectCollection(string name, CategoryValue categoryValue)
        {
            var categoryValueString = categoryValue.ToString();

            var effectCollection = _mongoContext.Database.GetCollection <Effect>(nameof(Effect));
            var isDuplicate      = await MongoHelper <Effect> .IsDuplicate(Constants.Name, name, effectCollection, null);

            if (!isDuplicate)
            {
                // Get category by name.
                var categoryCollection = _mongoContext.Database.GetCollection <Category>(nameof(Category));
                var bsonFilter         = Builders <Category> .Filter.Eq(nameof(Category.Name), categoryValueString);

                var category = await categoryCollection.Find(bsonFilter, _findOptions).SingleOrDefaultAsync();

                var effect = new Effect {
                    Name = name, CategoryId = category.ObjectId
                };
                await effectCollection.InsertOneAsync(effect);

                Log.Info($"Inserted effect {name} with Id {effect.ObjectId} into database.");
            }
        }
Exemplo n.º 12
0
 private Subcategory(SubcategoryId subcategoryId, SubcategoryName name, CategoryValue category) : base(subcategoryId)
 {
     this.name     = name;
     this.Category = category;
     concepts      = new List <ConceptObject>();
 }
Exemplo n.º 13
0
        public async Task <IEnumerable <Concept> > GetFromCategory(CategoryValue category)
        {
            var concepts = await repository.GetConceptsFromSubcategory(new SubcategoryId(id));

            return(concepts);
        }
Exemplo n.º 14
0
 public Category(CategoryValue value)
 {
     Value = value;
 }
Exemplo n.º 15
0
        private IList <CategoryWeight> GetWeightDataFromQuestrade(Category category, Security security)
        {
            var symbolData = GetSymbols(new[] { security }).Single();
            var values     = _categoryRepository.GetValues(category);
            var list       = new List <CategoryWeight>();

            if (category.Name.Equals("security", StringComparison.InvariantCultureIgnoreCase))
            {
                string categoryValueName;
                switch (symbolData.m_securityType)
                {
                case SecurityType.Stock:
                    categoryValueName = "Stock";
                    break;

                case SecurityType.Bond:
                    categoryValueName = "Bond";
                    break;

                default:
                    throw new Exception(string.Format("Questrade security type not supported: {0}", symbolData.m_securityType));
                }

                var value = values.SingleOrDefault(v => v.Name.Equals(categoryValueName));
                if (value == null)
                {
                    value = new CategoryValue {
                        Category = category, Name = categoryValueName
                    };
                    _categoryRepository.AddValues(category, new[] { value });
                }
                list.Add(new CategoryWeight {
                    Security = security, Weight = 100M, Value = value
                });
            }
            else if (category.Name.Equals("currency", StringComparison.InvariantCultureIgnoreCase))
            {
                var value = values.SingleOrDefault(v => v.Name.Equals(symbolData.m_currency));
                if (value == null)
                {
                    value = new CategoryValue {
                        Category = category, Name = symbolData.m_currency
                    };
                    _categoryRepository.AddValues(category, new[] { value });
                }
                list.Add(new CategoryWeight {
                    Security = security, Weight = 100M, Value = value
                });
            }
            else
            {
                throw new CategoryNotSupportedException(string.Format("Category not supported: {0}", category.Name));
            }

            if (!list.Any())
            {
                return(new List <CategoryWeight>());
            }

            _categoryRepository.AddWeights(category, security, list);
            return(list);
        }
Exemplo n.º 16
0
 public void Delete(CategoryValue value)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
 public static Subcategory Create(Guid id, string name, CategoryValue category)
 => new Subcategory(new SubcategoryId(id), new SubcategoryName(name), category);
Exemplo n.º 18
0
 public bool IsChildOf(CategoryValue category) => this.Category == category;
Exemplo n.º 19
0
        public void OnApplyPressed()
        {
            // Item type
            TypeValue typeFilter = new TypeValue(Type_Value.Activities);

            // Category
            Category_Value cv     = Category_Value.All;
            int            numSet = 0;

            if (model.physicalActivityToggle.value)
            {
                numSet++;
                cv |= Category_Value.Physical_Activities;
            }
            if (model.healthWellnessToggle.value)
            {
                numSet++;
                cv |= Category_Value.Health_Wellness;
            }
            if (model.foodNutritionToggle.value)
            {
                numSet++;
                cv |= Category_Value.Food_Nutrition;
            }

            if (numSet >= global::System.Enum.GetNames(typeof(Category_Value)).Length - 1)
            {
                cv = Category_Value.All;
            }

            CategoryValue categoryFilter = new CategoryValue(cv);


            // Audience
            Audience_Value av = Audience_Value.All;

            numSet = 0;
            if (model.audienceKidsToggle.value)
            {
                numSet++;
                av |= Audience_Value.Children;
            }
            if (model.audienceTeensToggle.value)
            {
                numSet++;
                av |= Audience_Value.Teenagers;
            }
            if (model.audienceAdultsToggle.value)
            {
                numSet++;
                av |= Audience_Value.Adults;
            }
            if (model.audienceSeniorsToggle.value)
            {
                numSet++;
                av |= Audience_Value.Senior_Citizen;
            }

            if (numSet >= global::System.Enum.GetNames(typeof(Audience_Value)).Length - 1)
            {
                av = Audience_Value.All;
            }

            AudienceValue audienceFilter = new AudienceValue(av);


            // Skill
            SkillLevel_Value sv = SkillLevel_Value.All;

            numSet = 0;
            if (model.skillBeginnerToggle.value)
            {
                numSet++;
                sv |= SkillLevel_Value.Beginner_Friendly;
            }
            if (model.skillIntermediateToggle.value)
            {
                numSet++;
                sv |= SkillLevel_Value.Intermediate;
            }
            if (model.skillAdvancedToggle.value)
            {
                numSet++;
                sv |= SkillLevel_Value.Advanced;
            }
            if (model.skillExpertToggle.value)
            {
                numSet++;
                sv |= SkillLevel_Value.Expert;
            }

            if (numSet >= global::System.Enum.GetNames(typeof(SkillLevel_Value)).Length - 1)
            {
                sv = SkillLevel_Value.All;
            }

            SkillLevelValue skillFilter = new SkillLevelValue(sv);

            //Distance
            int           distance       = CalculateDistance();
            DistanceValue distanceFilter = new DistanceValue(distance);

            //Admission
            Admission_Value admissionType = Admission_Value.All;

            if (model.priceFreeToggle.value)
            {
                admissionType = Admission_Value.Free;
            }
            if (model.pricePaidToggle.value)
            {
                admissionType = Admission_Value.Fee;
            }

            if (model.priceFreeToggle.value == model.pricePaidToggle.value)
            {
                admissionType = Admission_Value.All;
            }

            AdmissionValue admissionFilter = new AdmissionValue(admissionType);

            ITTFilterRequest filterRequest = new ITTFilterRequest();

            filterRequest.AddFilterValue(typeFilter);
            filterRequest.AddFilterValue(categoryFilter);
            filterRequest.AddFilterValue(audienceFilter);
            filterRequest.AddFilterValue(skillFilter);
            filterRequest.AddFilterValue(distanceFilter);
            filterRequest.AddFilterValue(admissionFilter);
            filterRequest.AddFilterValue(new MinDateValue(DateTime.Today));

            ITTGoogleAnalytics.Instance.googleAnalytics.LogEvent(new EventHitBuilder()
                                                                 .SetEventCategory("Filter - Filter Screen")
                                                                 .SetEventAction("Click - Filter Apply Button")
                                                                 .SetEventLabel("User has clicked on the apply button with the following url values: " + filterRequest.RetrieveFilterURLString()));
            filterResultsController._filterRequest    = filterRequest;
            ITTMainSceneManager.Instance.currentState = ITTMainSceneManager.ITTStates.FilterResults;
        }
Exemplo n.º 20
0
        public void ToString_Categories_ReturnsSelectedCategoriesAsBinaryStringFlags(CategoryValue values, string expectedResult)
        {
            var category = new Category(values);

            Assert.That(category.ToString(), Is.EqualTo(expectedResult));
        }
Exemplo n.º 21
0
 public Category(CategoryValue value) : this(new Record <CategoryValue>(default(int), value))
 {
 }
Exemplo n.º 22
0
 public Category(CategoryValue value, params SubcategoryObject[] subcategories)
 {
     this.value = value;
     categories = subcategories.ToList();
 }
Exemplo n.º 23
0
 public void Insert(CategoryValue value)
 {
     throw new NotImplementedException();
 }