Example #1
0
        public HandSets GetCompleteHandSetData()
        {
            string          brand, model;
            HandSets        returnVal   = new HandSets();
            HandSetFeatures currentNode = null;

            var featuresCollection = madCalmDB.GetCollection <BsonDocument>("features_new3");
            var brandsCollection   = madCalmDB.GetCollection <BsonDocument>("brands");

            var brandCursor = brandsCollection.Find(new BsonDocument()).ToCursor();
            var orderBy     = Builders <BsonDocument> .Sort.Ascending("Brand");

            var orderBy2 = Builders <BsonDocument> .Sort.Ascending("Model");

            var    featureCur = featuresCollection.Find(new BsonDocument()).Sort(orderBy).Sort(orderBy2).ToCursor();
            string currentBrand, currentModel;

            currentBrand = currentModel = "";

            foreach (var doc in featureCur.ToEnumerable())
            {
                if (doc == null)
                {
                    throw new Exception("Null exception!");
                }
                brand = doc.GetElement("Brand").Value.ToString();

                model = doc.GetElement("Model").Value.ToString();

                if ((currentBrand != brand) || (currentModel != model))
                {
                    currentNode = new HandSetFeatures(doc);

                    currentBrand = brand;
                    currentModel = model;
                    returnVal.Add(currentNode);
                }
                else
                {
                    currentNode.Colors.Add(doc.GetElement("Color").Value.ToString());
                }
            }


            foreach (var doc in brandCursor.ToEnumerable())
            {
                returnVal.SetBrandLogo(doc.GetElement("brand").Value.ToString().ToLower(), doc.GetElement("imageURL").Value.ToString());
            }

            return(returnVal);
        }
Example #2
0
            public void Add(HandSetFeatures newModel)
            {
                HandSetFeatures old;

                if (!models.TryGetValue(newModel.Model, out old))
                {
                    models.Add(newModel.Model, newModel);
                    spaceLess.Add(Miscellany.RemoveSpaces(newModel.Model), newModel);
                }
                else
                {
                    newModel.CopyTo(old);
                }
            }
Example #3
0
        public void Add(HandSetFeatures newModel)
        {
            Models brandModels;


            if (!brands.TryGetValue(newModel.Brand, out brandModels))
            {
                brands.Add(newModel.Brand, new Models());
                brands[newModel.Brand].Add(newModel);
                masterDict.Add(newModel);
            }
            else
            {
                masterDict.Add(newModel);
                brandModels.Add(newModel);
            }
        }
 public void CopyTo(HandSetFeatures other)
 {
     other.Brand    = Brand;
     other.Model    = Model;
     other.ImageURL = ImageURL;
 }
Example #5
0
        public double GetModelSize(string model)
        {
            HandSetFeatures features = masterDict.GetEquipmentFeatures(model);

            return(Miscellany.Product(features.BodySize));
        }