public ActionResult Create(SubCategories subCategories, string PostMethod)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             var viewModel = new CatSubCatViewModel
             {
                 subCategories = subCategories,
                 categories    = _context.categories.ToList()
             };
         }
         subCategories.ApplicationUserCreatedById     = "4af95f1c-0f73-4df9-bb6d-166a07b6e5f4";
         subCategories.ApplicationUserCreatedDate     = DateTime.Now;
         subCategories.ApplicationUserLastUpdatedById = subCategories.ApplicationUserCreatedById;
         subCategories.ApplicationUserLastUpdatedDate = DateTime.Now;
         // TODO: Add insert logic here
         _context.subCategories.Add(subCategories);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 2
0
        public JsonResult Delete(int id)
        {
            try
            {
                if (id == 0)
                {
                    return(Json(new { responseCode = "-10" }));
                }


                SubCategories model = this._subCategoriesBusiness.Get(id);
                model.Enable = false;
                this._subCategoriesBusiness.Save(model);

                var responseObject = new
                {
                    responseCode = 0
                };
                return(Json(responseObject));
            }
            catch (Exception)
            {
                return(Json(new { responseCode = "-10" }));
            }
        }
Ejemplo n.º 3
0
        public static List <CollectionListItem> GetSubCategoryList(int id, bool forceRefresh = false)
        {
            if (SubCategories.ContainsKey(id) && !forceRefresh)
            {
                return(SubCategories[id]);
            }

            WallpaperResponse response = Get(buildUrl(LookupMethods.sub_category_list, InfoLevels.Basic, 1, 0, 0, SizeOperators.Equal, id));

            if (response == null)
            {
                LastResult = "An unknown error has occured!";
            }
            else if (response.SubCategories == null)
            {
                LastResult = response.ErrorMessage;
            }
            else
            {
                if (SubCategories.ContainsKey(id))
                {
                    SubCategories[id] = new List <CollectionListItem>(response.SubCategories);
                }
                else
                {
                    SubCategories.Add(id, new List <CollectionListItem>(response.SubCategories));
                }

                return(SubCategories[id]);
            }
            return(new List <CollectionListItem>());
        }
        public void Delete(int subCategoriesId)
        {
            SubCategories subCategories = GetById(subCategoriesId);

            _subCategoriesRepository.Delete(subCategories);
            _unitOfWork.Complete();
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PutSubCategories([FromRoute] int id, [FromBody] SubCategories subCategories)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != subCategories.SubCategoryId)
            {
                return(BadRequest());
            }

            _context.Entry(subCategories).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubCategoriesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 6
0
        public IActionResult GetImage(int DatasetId, int UserId)
        {
            DatasetSubcategoryMapping datasetSubcategoryMapping = _context.DatasetSubcategoryMapping.Where(x => x.DatasetId == DatasetId).SingleOrDefault();

            if (datasetSubcategoryMapping != null)
            {
                SubCategories sourcetableName = _context.SubCategories.Find(datasetSubcategoryMapping.SourceSubcategoryId);
                SubCategories destTableName   = _context.SubCategories.Find(datasetSubcategoryMapping.DestinationSubcategoryId);

                if (sourcetableName.Name == "Images")
                {
                    int         langId = _context.UserInfo.FirstOrDefault(x => x.UserId == UserId).LangId1;
                    List <long> Images;
                    if (DatasetId == 2)//TODO
                    {
                        Images = iMAGEContext.Images.Where(x => x.DatasetId == DatasetId).Select(user => user.DataId).ToList();
                    }
                    else
                    {
                        Images = iMAGEContext.Images.Where(x => x.DatasetId == DatasetId && x.LangId == langId).Select(user => user.DataId).ToList();
                    }

                    if (destTableName.Name == "ImageText")
                    {
                        List <long> UserData = imageToTextContext.ImageText.Where(user => user.UserId == UserId).Select(user => user.DataId).Distinct().ToList();
                        List <long> linq     = Images.Except(UserData).ToList();
                        return(Ok(new { ImageString = iMAGEContext.Images.Find(linq.First()).Image, DataId = linq.First() }));
                    }
                }
            }
            return(NotFound());
        }
Ejemplo n.º 7
0
 public ActionResult AddCategories(SubCategories sc)
 {
     _subcontext.Add(sc);
     _subcontext.SaveChanges();
     ViewBag.message = sc.Scname + " has got successfully Added";
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 8
0
        internal BCategory(Category category, bool loadFirms, bool loadProducts)
        {
            category.ExcIfNull();

            this.ID          = category.ID;
            this.Name        = category.Name;
            this.Description = category.Description.GetTrimmed();

            this.SubCategories = new List <BCategory>();
            if (category.ChildCategories.AreThereItems() == true)
            {
                foreach (Category cat in category.ChildCategories)
                {
                    SubCategories.Add(new BCategory(cat, loadFirms, loadProducts));
                }
            }

            this.Firms = new List <BFirm>();
            if (loadFirms == true && category.Firms.AreThereItems() == true)
            {
                foreach (Firm_Category fc in category.Firms)
                {
                    this.Firms.Add(new BFirm(fc.Firm));
                }
            }

            this.Products = new List <BProduct>();
            if (loadProducts == true)
            {
                this.LoadProducts(category);
            }
        }
Ejemplo n.º 9
0
        public ActionResult SubCategory(SubCategories subcategories)
        {
            var selectedAttribute = subcategories.selectedAttribute.Where(x => x.IsSelected == true).ToList();

            try
            {
                SubCategories Cat = new SubCategories();
                AttributeItem att = new AttributeItem();
                Cat.SubCategoryName = subcategories.SubCategoryName;
                Cat.MainCat_ID      = subcategories.MainCat_ID;
                //Cat.selectedAttribute = subcategories.selectedAttribute;
                Cat.SelectedAttributes = string.Join(",", selectedAttribute.Select(x => x.AttributeID));
                db.SubCategories.Add(Cat);
                db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 10
0
        public NodeCategoryViewModel(string name, IEnumerable <NodeSearchElementViewModel> entries, IEnumerable <NodeCategoryViewModel> subs)
        {
            ClickedCommand = new DelegateCommand(Expand);

            Name          = name;
            this.entries  = new ObservableCollection <NodeSearchElementViewModel>(entries.OrderBy(x => x.Name));
            subCategories = new ObservableCollection <NodeCategoryViewModel>(subs.OrderBy(x => x.Name));

            foreach (var category in SubCategories)
            {
                category.PropertyChanged += CategoryOnPropertyChanged;
            }

            Entries.CollectionChanged       += OnCollectionChanged;
            SubCategories.CollectionChanged += OnCollectionChanged;
            SubCategories.CollectionChanged += SubCategoriesOnCollectionChanged;

            items = new ObservableCollection <ISearchEntryViewModel>(
                SubCategories.Cast <ISearchEntryViewModel>().Concat(Entries));

            Items.CollectionChanged += ItemsOnCollectionChanged;

            foreach (var item in Items)
            {
                item.PropertyChanged += ItemOnPropertyChanged;
            }

            Visibility = true;
            IsExpanded = false;
        }
Ejemplo n.º 11
0
        public IActionResult UploadText(int UserId, int DataId, int DatasetId, string Text, int LangId = 0)
        {
            DatasetSubcategoryMapping datasetSubcategoryMapping = _context.DatasetSubcategoryMapping.Where(x => x.DatasetId == DatasetId).SingleOrDefault();
            SubCategories             destTableName             = _context.SubCategories.Find(datasetSubcategoryMapping.DestinationSubcategoryId);

            if (destTableName.Name == "ImageText")
            {
                try
                {
                    ImageText imageText = new ImageText
                    {
                        UserId       = UserId,
                        DataId       = DataId,
                        DomainId     = iMAGEContext.Images.Where(x => x.DataId == DataId).FirstOrDefault().DomainId,
                        OutputData   = Text,
                        OutputLangId = _context.UserInfo.SingleOrDefault(x => x.UserId == UserId).LangId1,
                        DatasetId    = DatasetId,
                        AddedOn      = DateTime.Now
                    };
                    imageToTextContext.ImageText.Add(imageText);
                    imageToTextContext.SaveChanges();
                    return(Ok(true));
                }
                catch (Exception ex)
                {
                    return(BadRequest(false));
                }
            }
            else if (destTableName.Name == "TextText")
            {
                try
                {
                    TextText textText = new TextText
                    {
                        UserId       = UserId,
                        DataId       = DataId,
                        LangId       = _context.UserInfo.SingleOrDefault(x => x.UserId == UserId).LangId1,
                        DomainId     = _TEXTContext.Text.FirstOrDefault(x => x.DataId == DataId).DomainId,
                        OutputData   = Text,
                        OutputLangId = _context.UserInfo.SingleOrDefault(x => x.UserId == UserId).LangId1,
                        DatasetId    = DatasetId,
                        AddedOn      = DateTime.Now
                    };
                    textContext.TextText.Add(textText);
                    textContext.SaveChanges();
                    jsonResponse.IsSuccessful = true;
                    jsonResponse.Response     = "Text aved";
                    return(Ok(jsonResponse));
                }
                catch (Exception)
                {
                    jsonResponse.IsSuccessful = false;
                    jsonResponse.Response     = "Text not saved";
                    return(BadRequest(jsonResponse));
                }
            }
            jsonResponse.IsSuccessful = false;
            jsonResponse.Response     = "Text not saved";
            return(BadRequest(jsonResponse));
        }
        public ActionResult Edit(int id, SubCategories subCategories)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var viewModel = new CatSubCatViewModel
                    {
                        subCategories = subCategories,
                        categories    = _context.categories.ToList()
                    };

                    //return View("CustomerForm", viewModel);
                }
                // TODO: Add update logic here
                var subcatinDb = _context.subCategories.Single(s => s.Id == subCategories.Id);
                subcatinDb.CategoryID    = subCategories.CategoryID;
                subcatinDb.SubCatDesc    = subCategories.SubCatDesc;
                subcatinDb.TimeInMinutes = subCategories.TimeInMinutes;

                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Index"));
            }
        }
Ejemplo n.º 13
0
        protected virtual void Expand()
        {
            var endState = !IsExpanded;

            //foreach (var ele in this.Siblings)
            //    ele.IsExpanded = false;

            //Walk down the tree expanding anything nested one layer deep
            //this can be removed when we have the hierachy implemented properly
            if (Items.Count == 1 && SubCategories.Any())
            {
                var subElement = SubCategories[0];
                while (subElement.Items.Count == 1)
                {
                    subElement.IsExpanded = true;
                    if (subElement.SubCategories.Any())
                    {
                        subElement = subElement.SubCategories[0];
                    }
                    else
                    {
                        break;
                    }
                }

                subElement.IsExpanded = true;
            }

            IsExpanded = endState;
        }
Ejemplo n.º 14
0
        public override void LoadData()
        {
            base.LoadData();
            CategoryOrderItems = BistroDatabase.Instance.Get <CategoryOrderItem>(DBQuery.GET_CATEGORY_ORDER_ITEM).ToObservableCollection();
            IEnumerable <SubCategory> subCategory = BistroDatabase.Instance.Get <SubCategory>(DBQuery.GET_SUB_CATEGORIES);

            SubCategories.AddRange(subCategory);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Converts string form of this class to an actual FilterType.
        /// </summary>
        /// <param name="value">string form of a FilterType</param>
        /// <returns>FilterType object</returns>
        /// <history>
        /// [Curtis_Beard]	   10/31/2014	ADD: exclusions update
        /// </history>
        public static FilterType FromString(string value)
        {
            var           values = value.Split(DELIMETER);
            Categories    cat    = (Categories)Enum.Parse(typeof(Categories), values[0]);
            SubCategories subcat = (SubCategories)Enum.Parse(typeof(SubCategories), values[1]);

            return(new FilterType(cat, subcat));
        }
Ejemplo n.º 16
0
 private void ResetFields()
 {
     OrderItemName       = string.Empty;
     Description         = string.Empty;
     Price               = 0;
     IsEditMode          = false;
     SelectedSubCategory = SubCategories.FirstOrDefault();
 }
        public ActionResult DeleteConfirmed(int id)
        {
            SubCategories subCategories = db.subCategories.Find(id);

            db.subCategories.Remove(subCategories);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 18
0
        public void RemoveSubCategories(IList list)
        {
            var itemsToDelete         = new List <Item>();
            var subCategoriesToDelete = list.Cast <SubCategory>().ToList();

            foreach (var subCategory in subCategoriesToDelete)
            {
                itemsToDelete.AddRange(
                    _shop.Items.Where(
                        x =>
                        x.CategoryId == SelectedCategoryIndex &&
                        x.SubCategoryId == SubCategories.IndexOf(subCategory)
                        )
                    );
            }

            _shop.Items.RemoveRange(itemsToDelete);

            #region MoveItems

            var index = -1;

            for (int i = 0; i < _shop.Items.Count; i++)
            {
                if (_shop.Items[i].CategoryId == SelectedCategoryIndex)
                {
                    index++;

                    int subCat = _shop.Items[i].SubCategoryId;
                    int j      = i;

                    for (; j < _shop.Items.Count; j++)
                    {
                        if (subCat == _shop.Items[j].SubCategoryId)
                        {
                            while (_shop.Items[j].SubCategoryId > index)
                            {
                                _shop.Items[j].SubCategoryId--;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    i = j - 1;
                }
            }

            #endregion

            _subCategories.RemoveRange(subCategoriesToDelete);

            NotifyOfPropertyChange(nameof(SubCategories));
            NotifyOfPropertyChange(nameof(Items));
        }
Ejemplo n.º 19
0
        public ProductTreeLookup FindGroup(string name)
        {
            if (SubCategories == null)
            {
                LoadSubCategories();
            }

            return(SubCategories.FirstOrDefault(d => d.Name == name));
        }
Ejemplo n.º 20
0
        private void Update(SubCategories view)
        {
            SubCategories model = Get(view.Id);

            model.Name       = view.Name;
            model.CategoryId = view.CategoryId;

            this.repository.Update(view);
        }
Ejemplo n.º 21
0
        public void AddSubCategory([NotNull] XmlDataQualityCategory xmlSubCategory)
        {
            if (SubCategories == null)
            {
                SubCategories = new List <XmlDataQualityCategory>();
            }

            SubCategories.Add(xmlSubCategory);
        }
Ejemplo n.º 22
0
 public ActionResult Edit(SubCategories subCategories)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subCategories).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(subCategories));
 }
Ejemplo n.º 23
0
        public void AddItem(ITreeViewItem item)
        {
            SubCategory category = item as SubCategory;

            if (category.IsNullObj())
            {
                return;
            }
            SubCategories.Add(category);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Removes top x subcategories, where x is defined by input parameter.
        /// </summary>
        /// <param name="howMany">Indicates how many subcategories you want to remove.</param>
        public void RemoveLastSubcategories(int howMany)
        {
            int count = SubCategories.Count;

            for (int i = count - 1; i > count - howMany - 1; --i)
            {
                SubCategories.RemoveAt(i);
            }
            Parent.IsResultChanged = true;
        }
Ejemplo n.º 25
0
 public static SubCategoryDTO AsDTO(this SubCategories subcategory)
 {
     return(new SubCategoryDTO
     {
         Id = subcategory.Id,
         CategoryID = subcategory.CategoryID,
         Name = subcategory.Name,
         Brands = subcategory.Brands.Select(b => b.AsDTO()).ToList()
     });
 }
Ejemplo n.º 26
0
        public void AddItem(int index, ITreeViewItem item)
        {
            SubCategory category = item as SubCategory;

            if (category.IsNullObj())
            {
                return;
            }
            SubCategories.Insert(index, category);
        }
Ejemplo n.º 27
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                int           subCatId     = Convert.ToInt32(hdnCatId.Value);
                int           catId        = Convert.ToInt32(hdnCurrentSubCatCatId.Value);
                SubCategories _otherSubCat = bSubCategory.List().Where(m => m.Category_Id == catId && m.SubCategory_Id != subCatId & m.SubCategory_Title == txtCategory.Text).FirstOrDefault();
                int           adminId      = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()]);
                if (_otherSubCat == null)
                {
                    SubCategories SubCategories = bSubCategory.List().Where(m => m.SubCategory_Id == subCatId).FirstOrDefault();
                    SubCategories.SubCategory_Title       = txtCategory.Text;
                    SubCategories.SubCategory_UpdatedDate = DateTime.Now;
                    SubCategories.Administrators_Id       = adminId;
                    SubCategories.Category_Id             = Convert.ToInt32(ddlCategory.SelectedValue);
                    SubCategories.SubCategory_Status      = (chkIsActive.Checked) ? eStatus.Active.ToString() : eStatus.InActive.ToString();

                    SubCategories = bSubCategory.Update(SubCategories);

                    if (string.IsNullOrEmpty(SubCategories.ErrorMessage) && SubCategories.SubCategory_Status == eStatus.InActive.ToString())
                    {
                        List <Product> products = new List <Product>();
                        products = bProduct.List().Where(m => m.Product_Status == eProductStatus.Published.ToString() && m.SubCategory.SubCategory_Id == SubCategories.SubCategory_Id).ToList();

                        foreach (var item in products)
                        {
                            item.Product_Status = eProductStatus.ReviewPending.ToString();
                            bProduct.Update(item);
                            ProductHelper.CreateProductFlow(item.Product_Id, item.Product_Title, adminId, "System", "Sub Category In Active : Product Updated and set to Review Pending Status", item.Product_Status);
                            bProduct.DeleteTopEight(item.Product_Id);
                            bProduct.DeleteProductFeature(item.Product_Id);
                            bProduct.DeleteCart(item.Product_Id);
                        }
                    }

                    ActivityHelper.Create("Update Sub Category", "Sub Category Updated On " + DateTime.Now.ToString("D") + " Successfully and Title is " + SubCategories.SubCategory_Title + ".", adminId);

                    Response.Redirect("/administration/categories/subcategory.aspx?id=2000&redirecturl=admin-category-RachnaTeracotta");
                }
                else
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblMessage.Text = "Oops!! Sub Category not updated successfully, sub category name should not be same as other.";
                }
            }
            catch (Exception ex)
            {
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "Oops!! " + ex.Message.ToString();
            }
        }
Ejemplo n.º 28
0
        public IActionResult GetValidationData_TextSpeech(int DatasetId, int UserId, int LanguageId, int DomainId)
        {
            if (DatasetId != 0 && UserId != 0 && LanguageId != 0 && DomainId != 0)
            {
                int?max_collection_user = context.Datasets.Where(x => x.DatasetId == DatasetId)
                                          .Select(x => x.MaxCollectionUsers)
                                          .FirstOrDefault();
                DatasetSubcategoryMapping datasetSubcategoryMapping = context.DatasetSubcategoryMapping
                                                                      .Where(x => x.DatasetId == DatasetId)
                                                                      .SingleOrDefault();

                if (datasetSubcategoryMapping != null)
                {
                    SubCategories sourcetableName = context.SubCategories.Find(datasetSubcategoryMapping.SourceSubcategoryId);
                    SubCategories destTableName   = context.SubCategories.Find(datasetSubcategoryMapping.DestinationSubcategoryId);

                    if (destTableName.Name == "TextSpeech")
                    {
                        if (max_collection_user != 0)
                        {
                            List <long> sentences  = validationInfoContext.TextspeechValidationResponseDetail.Where(x => x.UserId == UserId).Select(e => e.RefAutoid).ToList();
                            List <long> sentences1 = textToSpeech.TextSpeech.Where(x => x.UserId != UserId && x.IsValid == null &&
                                                                                   x.TotalValidationUsersCount < max_collection_user && x.LangId == LanguageId && x.DomainId == DomainId)
                                                     .Select(e => e.AutoId).ToList();
                            long id = sentences1.Except(sentences).FirstOrDefault();

                            ValidationTextSpeechModel validationTextSpeechModel = textToSpeech.TextSpeech.Where(x => x.AutoId == id)
                                                                                  .Select(e => new ValidationTextSpeechModel
                            {
                                DestAutoId      = e.AutoId,
                                SourceDataId    = e.DataId,
                                DestinationData = e.OutputData
                            }).FirstOrDefault();
                            validationTextSpeechModel.SourceData = _TEXTcontext.Text.Where(x => x.DataId == validationTextSpeechModel.SourceDataId).Select(e => e.Text1).FirstOrDefault();
                            validationTextSpeechModel.DatasetID  = DatasetId;

                            /*ValidationTextSpeechModel validationTextSpeechModel = textToSpeech.TextSpeech.Where(x => x.UserId != UserId && x.IsValid == null
                             *                 && x.TotalValidationUsersCount < max_collection_user && x.LangId == LanguageId && x.DomainId == DomainId )
                             *                 .Select(e => new ValidationTextSpeechModel
                             *                 {
                             *                     DestAutoId = e.AutoId,
                             *                     SourceDataId = e.DataId,
                             *                     DestinationData = e.OutputData
                             *                 }).FirstOrDefault();
                             * validationTextSpeechModel.SourceData = _TEXTcontext.Text.Where(x => x.DataId == validationTextSpeechModel.SourceDataId).Select(e => e.Text1).FirstOrDefault();
                             * validationTextSpeechModel.DatasetID = DatasetId;*/
                            return(Ok(validationTextSpeechModel));
                        }
                        return(NotFound());
                    }
                    return(NotFound());
                }
            }
            return(BadRequest());
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Creates an instance of this class with the required category and sub category.
        /// </summary>
        /// <param name="category">Selected category</param>
        /// <param name="subCategory">Selected sub category</param>
        /// <history>
        /// [Curtis_Beard]	   10/31/2014	ADD: exclusions update
        /// </history>
        public FilterType(Categories category, SubCategories subCategory)
        {
            cat = category;
             subcat = subCategory;

             switch (subcat)
             {
            case SubCategories.Name:
            case SubCategories.Path:
               valuetype = ValueTypes.String;
               supportedValueOptions = new List<ValueOptions>() { ValueOptions.Equals, ValueOptions.Contains, ValueOptions.StartsWith, ValueOptions.EndsWith };
               supportsIgnoreCase = true;
               supportsMulitpleItems = true;
               break;

            case SubCategories.Hidden:
            case SubCategories.System:
            case SubCategories.ReadOnly:
            case SubCategories.Binary:
               valuetype = ValueTypes.Null;
               supportedValueOptions = new List<ValueOptions>() { ValueOptions.None };
               supportsIgnoreCase = false;
               supportsMulitpleItems = false;
               break;

            case SubCategories.DateModified:
            case SubCategories.DateCreated:
               valuetype = ValueTypes.DateTime;
               supportedValueOptions = new List<ValueOptions>() { ValueOptions.Equals, ValueOptions.NotEquals, ValueOptions.GreaterThan, ValueOptions.GreaterThanEquals, ValueOptions.LessThan, ValueOptions.LessThanEquals };
               supportsIgnoreCase = false;
               supportsMulitpleItems = true;
               break;

            case SubCategories.Extension:
               valuetype = ValueTypes.String;
               supportedValueOptions = new List<ValueOptions>() { ValueOptions.None };
               supportsIgnoreCase = false;
               supportsMulitpleItems = true;
               break;

            case SubCategories.Size:
               valuetype = ValueTypes.Size;
               supportedValueOptions = new List<ValueOptions>() { ValueOptions.Equals, ValueOptions.NotEquals, ValueOptions.GreaterThan, ValueOptions.GreaterThanEquals, ValueOptions.LessThan, ValueOptions.LessThanEquals };
               supportsIgnoreCase = false;
               supportsMulitpleItems = true;
               break;

            case SubCategories.MinimumHitCount:
               valuetype = ValueTypes.Long;
               supportedValueOptions = new List<ValueOptions>() { ValueOptions.None };
               supportsIgnoreCase = false;
               supportsMulitpleItems = false;
               break;
             }
        }
Ejemplo n.º 30
0
        private List <int> GetSubCategoryTreeIds()
        {
            List <int> subs = new List <int>();

            // Add current category ID
            subs.Add(Id);
            // Add SubCategories Ids
            SubCategories.ForEach(s => subs.Add(s.Id));

            return(subs);
        }
Ejemplo n.º 31
0
        public static void Run()
        {
            Entities    db  = new Entities();
            XmlDocument doc = new XmlDocument();

            doc.Load(Program.BaseURL + "categories");
            string     xmlcontents = doc.InnerXml;
            XmlElement xelRoot     = doc.DocumentElement;

            XmlNodeList Categories = xelRoot.SelectNodes("/Categories/Category");

            foreach (XmlNode xndNode in Categories)
            {
                Categories c = new Categories();
                c.Name = xndNode["Name"].InnerText;
                var original = db.Categories.Find(xndNode["Name"].InnerText);
                if (original != null)
                {
                    db.Entry(original).CurrentValues.SetValues(c);
                    db.SaveChanges();
                }
                else
                {
                    db.Categories.Add(c);
                    XmlNodeList SubCategories = xndNode.SelectNodes("Subcategory");
                    foreach (XmlNode SubNode in SubCategories)
                    {
                        SubCategories sc = new SubCategories();
                        sc.Name        = SubNode["Name"].InnerText;
                        sc.Parent_Name = xndNode["Name"].InnerText;
                        db.SubCategories.Add(sc);

                        XmlNodeList SubSubCategories = SubNode.SelectNodes("Subsubcategory");
                        foreach (XmlNode SubSubNode in SubSubCategories)
                        {
                            SubSubCategories ssc = new SubSubCategories();
                            ssc.Name        = SubSubNode["Name"].InnerText;
                            ssc.Parent_Name = sc.Name;
                            var originalSubSub = db.SubSubCategories.Find(SubSubNode["Name"].InnerText);
                            if (originalSubSub != null)
                            {
                                db.Entry(originalSubSub).CurrentValues.SetValues(c);
                                db.SaveChanges();
                            }
                            else
                            {
                                db.SubSubCategories.Add(ssc);
                            }
                        }
                    }
                    db.SaveChanges();
                }
            }
        }