コード例 #1
0
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin dòng sản phẩm"), Url = Url.Action("Index")
            });
            var model = new ProductsGroupModel();

            if (id > 0)
            {
                model = this.service.GetById(id);
            }

            var result = new ControlFormResult <ProductsGroupModel>(model);

            result.Title                = this.T("Thông tin dòng sản phẩm");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowBoxHeader        = false;
            result.CancelButtonText     = T("Back");
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;
            result.RegisterFileUploadOptions("ImageUrl.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });
            result.RegisterFileUploadOptions("HomeImageUrl.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });
            return(result);
        }
コード例 #2
0
        public ActionResult Create()
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(new HttpUnauthorizedResult());
            }

            var result = new ControlFormResult <LanguageModel>(new LanguageModel {
                Active = true
            })
            {
                Title                = T("Create Language"),
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.RegisterFileUploadOptions("ImageFlag.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

            result.RegisterExternalDataSource(x => x.CultureCode, cultures.ToList().OrderBy(x => x.DisplayName).ToDictionary(k => k.Name, v => v.DisplayName));

            var themeManager = WorkContext.Resolve <IThemeManager>();

            result.RegisterExternalDataSource(x => x.Theme, themeManager.GetInstalledThemes());

            result.ExcludeProperty(x => x.CultureCode2);

            return(result);
        }
コード例 #3
0
        public ActionResult Create()
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý đối tác"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thêm thông tin đối tác"), Url = Url.Action("Index")
            });
            var model = new PartnerModel();

            var result = new ControlFormResult <PartnerModel>(model);

            result.Title                = this.T("Thêm thông tin đối tác");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.RegisterFileUploadOptions("Logo.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.AddAction().HasText(this.T("Thêm mới")).HasUrl(this.Url.Action("Create")).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);
            return(result);
        }
コード例 #4
0
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý cửa hàng phân phối"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin cửa hàng phân phối"), Url = Url.Action("Index")
            });
            var model = new StoreBranchModel();

            if (id > 0)
            {
                model = this.service.GetById(id);
            }

            var result = new ControlFormResult <StoreBranchModel>(model);

            result.Title                = this.T("Thông tin cửa hàng phân phối");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.RegisterFileUploadOptions("LogoUrl.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.AddAction().HasText(this.T("Clear")).HasUrl(this.Url.Action("Edit", RouteData.Values.Merge(new { id = 0 }))).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);
            return(result);
        }
コード例 #5
0
 protected override void OnEditing(ControlFormResult <SlideModel> controlForm)
 {
     controlForm.RegisterExternalDataSource(x => x.SlideDirection, "left", "right", "top", "bottom", "fade");
     controlForm.RegisterFileUploadOptions("BackgroundUrl.FileName", new ControlFileUploadOptions
     {
         AllowedExtensions = "jpg,jpeg,png,gif"
     });
     base.OnEditing(controlForm);
 }
コード例 #6
0
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý bài viết"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin bài viết"), Url = Url.Action("Index")
            });
            var model = new ArticlesModel();

            if (id > 0)
            {
                var service = WorkContext.Resolve <IArticlesService>();
                model = service.GetById(id);
            }

            var result = new ControlFormResult <ArticlesModel>(model);

            result.Title                = this.T("Thông tin bài viết");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.RegisterFileUploadOptions("BannerUrl.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.RegisterFileUploadOptions("Image.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.AddAction().HasText(this.T("Clear")).HasUrl(this.Url.Action("Edit", RouteData.Values.Merge(new { id = 0 }))).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);

            result.RegisterExternalDataSource(x => x.CategoryId, y => BindCategories());

            return(result);
        }
コード例 #7
0
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(new HttpUnauthorizedResult());
            }

            LanguageModel model = languageService.GetById(id);

            model.CultureCode2 = model.CultureCode;

            var result = new ControlFormResult <LanguageModel>(model)
            {
                Title                = T("Edit Language"),
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            if (model.CultureCode == siteSettings.DefaultLanguage)
            {
                result.ExcludeProperty(x => x.Active);
                result.AddHiddenValue("Active", "true");
            }

            result.RegisterFileUploadOptions("ImageFlag.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            var themeManager = WorkContext.Resolve <IThemeManager>();

            result.RegisterExternalDataSource(x => x.Theme, themeManager.GetInstalledThemes());

            result.ExcludeProperty(x => x.CultureCode);
            result.AddHiddenValue("CultureCode", model.CultureCode);

            return(result);
        }
コード例 #8
0
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý đối tác"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Sửa thông tin đối tác"), Url = Url.Action("Index")
            });

            var          service   = WorkContext.Resolve <IPartnerService>();
            var          records   = service.GetRecords(x => x.Id == id || x.RefId == id);
            PartnerModel model     = records.First(x => x.Id == id);
            var          modelType = model.GetType();

            var result = new ControlFormResult <PartnerModel>(model);

            result.Title            = this.T("Sửa thông tin đối tác");
            result.FormMethod       = FormMethod.Post;
            result.Layout           = ControlFormLayout.Tab;
            result.UpdateActionName = "Update";
            result.ShowCancelButton = false;
            result.ShowBoxHeader    = false;

            result.RegisterFileUploadOptions("Logo.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            var mainTab           = result.AddTabbedLayout("Thông tin chính");
            var mainGroup         = mainTab.AddGroup();
            var allFields         = modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var controlAttributes = new Dictionary <string, ControlFormAttribute>();

            foreach (var propertyInfo in allFields)
            {
                var controlAttribute = propertyInfo.GetCustomAttribute <ControlFormAttribute>(true);
                if (controlAttribute == null)
                {
                    continue;
                }
                mainGroup.Add(propertyInfo.Name);
                controlAttribute.PropertyInfo = propertyInfo;
                controlAttribute.PropertyType = propertyInfo.PropertyType;
                controlAttributes.Add(propertyInfo.Name, controlAttribute);
            }

            var languageManager = WorkContext.Resolve <ILanguageManager>();
            var languages       = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);
            var listHidden      = new List <string>
            {
                "Id", "SortOrder", "Logo", "PhoneNumber", "Email", "Website"
            };

            if (languages.Count > 0)
            {
                foreach (var language in languages)
                {
                    var languageTab       = result.AddTabbedLayout(language.Name);
                    var languageGroup     = languageTab.AddGroup();
                    var widgetForLanguage = records.FirstOrDefault(x => x.LanguageCode == language.CultureCode) ?? model;

                    foreach (var controlAttribute in controlAttributes)
                    {
                        if (listHidden.Contains(controlAttribute.Key))
                        {
                            continue;
                        }

                        var key   = controlAttribute.Key + "." + language.CultureCode;
                        var value = controlAttribute.Value.PropertyInfo.GetValue(widgetForLanguage);
                        result.AddProperty(key, controlAttribute.Value.ShallowCopy(), value);
                        languageGroup.Add(key);
                    }
                }
            }

            result.AddAction().HasText(this.T("Thêm mới")).HasUrl(this.Url.Action("Create")).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);
            return(result);
        }
コード例 #9
0
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý bài viết"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Sửa thông tin bài viết"), Url = Url.Action("Index")
            });

            var           service   = WorkContext.Resolve <IArticlesService>();
            var           records   = service.GetRecords(x => x.Id == id || x.RefId == id);
            ArticlesModel model     = records.First(x => x.Id == id);
            var           modelType = model.GetType();

            var result = new ControlFormResult <ArticlesModel>(model);

            result.Title            = this.T("Sửa thông tin bài viết");
            result.FormMethod       = FormMethod.Post;
            result.Layout           = ControlFormLayout.Tab;
            result.UpdateActionName = "Update";
            result.ShowCancelButton = false;
            result.ShowBoxHeader    = false;

            result.RegisterFileUploadOptions("Image.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.ExcludeProperty(x => x.Alias);
            result.ExcludeProperty(x => x.Contents);
            result.ExcludeProperty(x => x.Description);
            result.ExcludeProperty(x => x.Summary);
            result.ExcludeProperty(x => x.Tags);
            result.ExcludeProperty(x => x.Title);

            var mainTab           = result.AddTabbedLayout("Thông tin chính");
            var mainGroup         = mainTab.AddGroup();
            var allFields         = modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var controlAttributes = new Dictionary <string, ControlFormAttribute>();

            foreach (var propertyInfo in allFields)
            {
                var controlAttribute = propertyInfo.GetCustomAttribute <ControlFormAttribute>(true);
                if (controlAttribute == null)
                {
                    continue;
                }
                mainGroup.Add(propertyInfo.Name);
                controlAttribute.PropertyInfo = propertyInfo;
                controlAttribute.PropertyType = propertyInfo.PropertyType;
                controlAttributes.Add(propertyInfo.Name, controlAttribute);
            }

            var languageManager = WorkContext.Resolve <ILanguageManager>();
            var languages       = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);
            var listHidden      = new List <string>
            {
                "Id", "CategoryId", "Image", "IsDeleted", "IsPublished", "LanguageCode", "VideoUrl", "Year"
            };

            if (languages.Count > 0)
            {
                foreach (var language in languages)
                {
                    var languageTab       = result.AddTabbedLayout(language.Name);
                    var languageGroup     = languageTab.AddGroup();
                    var widgetForLanguage = records.FirstOrDefault(x => x.LanguageCode == language.CultureCode) ?? model;

                    foreach (var controlAttribute in controlAttributes)
                    {
                        if (listHidden.Contains(controlAttribute.Key))
                        {
                            continue;
                        }

                        var key   = controlAttribute.Key + "." + language.CultureCode;
                        var value = controlAttribute.Value.PropertyInfo.GetValue(widgetForLanguage);
                        result.AddProperty(key, controlAttribute.Value.ShallowCopy(), value);
                        languageGroup.Add(key);
                    }
                }
            }

            result.AddAction().HasText(T("Add Images")).HasUrl(Url.Action("Edit", "AdminImages", new { id = 0, cateId = 0, articlesId = model.Id })).HasButtonStyle(ButtonStyle.Info);
            result.AddAction().HasText(this.T("Thêm mới")).HasUrl(this.Url.Action("Create")).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);

            result.RegisterExternalDataSource(x => x.CategoryId, BindCategories());

            return(result);
        }
コード例 #10
0
 public ControlForm <TModel> RegisterFileUploadOptions <TValue>(Expression <Func <TModel, TValue> > expression, ControlFileUploadOptions options)
 {
     model.RegisterFileUploadOptions(expression, options);
     return(this);
 }