protected void SaveLocalizableContent(Category category)
        {
            if (category == null)
            {
                return;
            }

            if (!this.HasLocalizableContent)
            {
                return;
            }

            foreach (RepeaterItem item in rptrLanguageDivs.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    var txtLocalizedCategoryName = (TextBox)item.FindControl("txtLocalizedCategoryName");
                    var txtLocalizedDescription  = (FCKeditor)item.FindControl("txtLocalizedDescription");
                    var lblLanguageId            = (Label)item.FindControl("lblLanguageId");

                    int    languageId  = int.Parse(lblLanguageId.Text);
                    string name        = txtLocalizedCategoryName.Text;
                    string description = txtLocalizedDescription.Value;

                    bool allFieldsAreEmpty = (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(description));

                    var content = this.CategoryService.GetCategoryLocalizedByCategoryIdAndLanguageId(category.CategoryId, languageId);
                    if (content == null)
                    {
                        if (!allFieldsAreEmpty && languageId > 0)
                        {
                            //only insert if one of the fields are filled out (avoid too many empty records in db...)
                            content = new CategoryLocalized()
                            {
                                CategoryId  = category.CategoryId,
                                LanguageId  = languageId,
                                Name        = name,
                                Description = description
                            };

                            this.CategoryService.InsertCategoryLocalized(content);
                        }
                    }
                    else
                    {
                        if (languageId > 0)
                        {
                            content.LanguageId  = languageId;
                            content.Name        = name;
                            content.Description = description;

                            this.CategoryService.UpdateCategoryLocalized(content);
                        }
                    }
                }
            }
        }
Example #2
0
        public static Category GetCategoryPage(string slug)
        {
            //pull the category
            CategoryLocalized localized = null;

            if (!string.IsNullOrEmpty(slug))
            {
                localized = CategoryLocalized.SingleOrDefault(x => x.Slug.ToLower() == slug.ToLower() && x.LanguageCode == System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
            }

            //default is to pull the home page
            if (localized == null)
            {
                //it's a home page - pull em
                localized = CategoryLocalized.SingleOrDefault(x => x.IsHome && x.LanguageCode == System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
            }

            //shouldn't be null - if it is then we have an issue
            if (localized == null)
            {
                throw new Exception("There is no home category defined for the site - better set 'em");
            }

            Category result = Category.SingleOrDefault(x => x.CategoryID == localized.CategoryID);

            result.Name = localized.Name;
            result.Slug = localized.Slug;
            //set the products
            KonaDB db = new KonaDB();

            result.Products = (from p in db.Products
                               join ci in db.Categories_Products on p.SKU equals ci.SKU
                               select p).Distinct().ToList() ?? new List <Product>();

            //pull the widgets
            result.Widgets = (from w in db.Widgets
                              join cw in db.Categories_Widgets on w.WidgetID equals cw.WidgetID
                              select w).ToList() ?? new List <Widget>();


            //set the products for the Widget
            foreach (var widget in result.Widgets)
            {
                widget.Products = new List <Product>();
                foreach (string sku in widget.GetSkuArray())
                {
                    var widgetProduct = result.Products.SingleOrDefault(x => x.SKU.Equals(sku, StringComparison.InvariantCultureIgnoreCase));
                    if (widgetProduct != null)
                    {
                        widget.Products.Add(widgetProduct);
                    }
                }
            }


            return(result);
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            string  strPID = "50004";
            Product objProd;

            try
            {
                objPEE     = new ProductEngineInstance("en-us", DateTime.Now);
                objCatalog = objPEE.Catalogs["Fnet-US"];

                objProd = objCatalog.Products[strPID];
                //Set the category code for Product Family control
                CategoryLocalized objCatLocalized = objProd.DefaultCategory.Localized;

                //Set grid headers
                LinkTitle = "Download";
                dbAssets.Columns[0].HeaderText = "Title";
                dbAssets.Columns[2].HeaderText = "DOWNLOAD OPTIONS";

                //Assign datasource for the grid
                dbAssets.DataSource = getAssets(objProd);
                dbAssets.DataBind();
            }
            catch (ProductEngineException ex)
            {
                if (ExceptionPolicy.HandleException(DanaherTM.Framework.ExceptionHandling.ExceptionInstance.FlukeNetworks.CommonControls, ex))
                {
                    throw;
                }
            }
            catch (NullReferenceException ex)
            {
                if (ExceptionPolicy.HandleException(DanaherTM.Framework.ExceptionHandling.ExceptionInstance.FlukeNetworks.CommonControls, ex))
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(DanaherTM.Framework.ExceptionHandling.ExceptionInstance.FlukeNetworks.CommonControls, ex))
                {
                    throw;
                }
            }
            finally
            {
                objPEE.Dispose();
            }
        }
Example #4
0
        public ActionResult Edit(string slug, FormCollection form) {

            //pull it - this is the localized stuff
            //user can't edit other things
            CategoryLocalized loc = new CategoryLocalized(x => x.Slug == slug);

            //update it - the only thing people can change is the title/slug
            //so make sure it gets saved to the localized stuff
            UpdateModel<CategoryLocalized>(loc);

            //save it
            loc.Update(User.Identity.Name);

            if (!Request.IsAjaxRequest()) {
                return RedirectToAction("Index", new { slug = slug });
            } else {
                return new EmptyResult();
            }
        }
Example #5
0
        public ActionResult Edit(string slug, FormCollection form)
        {
            //pull it - this is the localized stuff
            //user can't edit other things
            CategoryLocalized loc = new CategoryLocalized(x => x.Slug == slug);

            //update it - the only thing people can change is the title/slug
            //so make sure it gets saved to the localized stuff
            UpdateModel <CategoryLocalized>(loc);

            //save it
            loc.Update(User.Identity.Name);

            if (!Request.IsAjaxRequest())
            {
                return(RedirectToAction("Index", new { slug = slug }));
            }
            else
            {
                return(new EmptyResult());
            }
        }
Example #6
0
        protected void SaveLocalizableContent(Category category)
        {
            if (category == null)
            {
                return;
            }

            if (!this.HasLocalizableContent)
            {
                return;
            }

            foreach (RepeaterItem item in rptrLanguageDivs.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    var txtLocalizedMetaKeywords    = (TextBox)item.FindControl("txtLocalizedMetaKeywords");
                    var txtLocalizedMetaDescription = (TextBox)item.FindControl("txtLocalizedMetaDescription");
                    var txtLocalizedMetaTitle       = (TextBox)item.FindControl("txtLocalizedMetaTitle");
                    var txtLocalizedSEName          = (TextBox)item.FindControl("txtLocalizedSEName");
                    var lblLanguageId = (Label)item.FindControl("lblLanguageId");

                    int    languageId      = int.Parse(lblLanguageId.Text);
                    string metaKeywords    = txtLocalizedMetaKeywords.Text;
                    string metaDescription = txtLocalizedMetaDescription.Text;
                    string metaTitle       = txtLocalizedMetaTitle.Text;
                    string seName          = txtLocalizedSEName.Text;

                    bool allFieldsAreEmpty = (string.IsNullOrEmpty(metaKeywords) &&
                                              string.IsNullOrEmpty(metaDescription) &&
                                              string.IsNullOrEmpty(metaTitle) &&
                                              string.IsNullOrEmpty(seName));

                    var content = this.CategoryService.GetCategoryLocalizedByCategoryIdAndLanguageId(category.CategoryId, languageId);
                    if (content == null)
                    {
                        if (!allFieldsAreEmpty && languageId > 0)
                        {
                            //only insert if one of the fields are filled out (avoid too many empty records in db...)
                            content = new CategoryLocalized()
                            {
                                CategoryId      = category.CategoryId,
                                LanguageId      = languageId,
                                MetaKeywords    = metaKeywords,
                                MetaDescription = metaDescription,
                                MetaTitle       = metaTitle,
                                SEName          = seName
                            };

                            this.CategoryService.InsertCategoryLocalized(content);
                        }
                    }
                    else
                    {
                        if (languageId > 0)
                        {
                            content.LanguageId      = languageId;
                            content.MetaKeywords    = metaKeywords;
                            content.MetaDescription = metaDescription;
                            content.MetaTitle       = metaTitle;
                            content.SEName          = seName;

                            this.CategoryService.UpdateCategoryLocalized(content);
                        }
                    }
                }
            }
        }