예제 #1
0
        protected void specTreeControl_OnEditItem(object sender, GenericEventArgs <Guid> e)
        {
            var entity = DataContext.LP_Specs.FirstOrDefault(n => n.ID == e.Value);

            if (entity == null)
            {
                return;
            }

            var converter = new SpecEntityModelConverter(DataContext);
            var model     = converter.Convert(entity);

            specCategoryControl.Model = model;
            specDataControl.Model     = model;

            if (model.IsCategory.GetValueOrDefault())
            {
                specCategoryControl.Visible = true;
                specDataControl.Visible     = false;

                rbType.TrySetSelectedValue("Category");
            }
            else
            {
                specCategoryControl.Visible = false;
                specDataControl.Visible     = true;

                rbType.TrySetSelectedValue("Data");
            }

            mpeAddEditSpec.Show();
        }
예제 #2
0
        protected void FillDataGrid()
        {
            var converter = new SpecEntityModelConverter(DataContext);

            var entities = (from n in DataContext.LP_Specs
                            where n.DateDeleted == null
                            orderby n.OrderIndex, n.DateCreated
                            select n).ToList();

            var models = entities.Select(n => converter.Convert(n)).ToList();

            var specsModel = new SpecsModel {
                List = models
            };

            specTreeControl.Model = specsModel;
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var currentLanguage = LanguageUtil.GetLanguage();
            var specID          = DataConverter.ToNullableGuid(Request["ID"]);

            var spec = DataContext.LP_Specs.FirstOrDefault(n => n.ID == specID);

            if (spec == null)
            {
                var mainSpecs = (from n in DataContext.LP_Specs
                                 where n.DateDeleted == null &&
                                 n.ParentID == null &&
                                 (n.Language == currentLanguage || n.Language == null || n.Language == "")
                                 select n).ToList();

                var converter = new SpecEntityModelConverter(DataContext);

                var models = (from n in mainSpecs
                              let c = converter.Convert(n)
                                      select c).ToList();

                var specsModel = new SpecsModel
                {
                    List = models
                };

                categoriesControl.Model = specsModel;

                pnlSpecData.Visible       = false;
                pnlSpecCategories.Visible = true;
            }
            else if (spec.IsCategory.GetValueOrDefault())
            {
                var mainSpecs = (from n in spec.Children
                                 where n.DateDeleted == null && (n.Language == currentLanguage || n.Language == null || n.Language == "")
                                 select n).ToList();

                var converter = new SpecEntityModelConverter(DataContext);

                var models = (from n in mainSpecs
                              let c = converter.Convert(n)
                                      select c).ToList();

                var specsModel = new SpecsModel
                {
                    List = models
                };

                categoriesControl.Model = specsModel;

                pnlSpecData.Visible       = false;
                pnlSpecCategories.Visible = true;
            }
            else
            {
                var converter = new SpecEntityModelConverter(DataContext);
                var model     = converter.Convert(spec);

                specControl.Model = model;

                pnlSpecData.Visible       = true;
                pnlSpecCategories.Visible = false;
            }
        }