Example #1
0
        public override void ExpandView(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            ListSupportedCulture = CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);
            ListSupportedCulture.ForEach(c => c.IsSupported = _context.SiocModule.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
            Columns = new List <ModuleFieldViewModel>();
            JArray arrField = !string.IsNullOrEmpty(Fields) ? JArray.Parse(Fields) : new JArray();

            foreach (var field in arrField)
            {
                ModuleFieldViewModel thisField = new ModuleFieldViewModel()
                {
                    Name       = CommonHelper.ParseJsonPropertyName(field["name"].ToString()),
                    Title      = field["title"]?.ToString(),
                    Options    = field["options"] != null ? field["options"].Value <JArray>() : new JArray(),
                    Priority   = field["priority"] != null ? field["priority"].Value <int>() : 0,
                    DataType   = (SWCmsConstants.DataType)(int) field["dataType"],
                    Width      = field["width"] != null ? field["width"].Value <int>() : 3,
                    IsUnique   = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true,
                    IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true,
                    IsDisplay  = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true,
                    IsSelect   = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false,
                    IsGroupBy  = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false,
                };
                Columns.Add(thisField);
            }
            int themeId = GlobalConfigurationService.Instance.GetLocalInt(SWCmsConstants.ConfigurationKeyword.ThemeId, Specificulture, 0);

            View = BETemplateViewModel.Repository.GetSingleModel(t =>
                                                                 t.TemplateId == themeId &&
                                                                 !string.IsNullOrEmpty(this.Template) && this.Template.Contains($"{t.FileName}{t.Extension}")).Data;
            if (this.View == null)
            {
                this.View = new BETemplateViewModel(new SiocTemplate()
                {
                    Extension    = SWCmsConstants.Parameters.TemplateExtension,
                    TemplateId   = themeId,
                    TemplateName = ActivedTemplate,
                    FolderType   = TemplateFolderType,
                    FileFolder   = this.TemplateFolder,
                    FileName     = SWCmsConstants.Default.DefaultTemplate,
                    ModifiedBy   = ModifiedBy,
                    Content      = "<div></div>"
                });
            }
            this.Template = SwCmsHelper.GetFullPath(new string[]
            {
                this.View?.FileFolder
                , this.View?.FileName
            });
        }
 public override async Task <RepositoryResponse <bool> > RemoveRelatedModelsAsync(ApiLanguageViewModel view, SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
 {
     foreach (var culture in ListSupportedCulture.Where(c => c.Specificulture != Specificulture))
     {
         var lang = _context.SiocLanguage.First(c => c.Keyword == Keyword && c.Specificulture == culture.Specificulture);
         if (lang != null)
         {
             _context.SiocLanguage.Remove(lang);
         }
     }
     return(new RepositoryResponse <bool>()
     {
         IsSucceed = (await _context.SaveChangesAsync()) > 0
     });
 }
Example #3
0
        public override void ExpandView(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            UrlAlias = ApiUrlAliasViewModel.Repository.GetSingleModel(u => u.Specificulture == Specificulture && u.SourceId == Id.ToString()).Data;
            if (UrlAlias == null)
            {
                UrlAlias = new ApiUrlAliasViewModel()
                {
                    Specificulture = Specificulture
                };
            }
            ListSupportedCulture = CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);
            ListSupportedCulture.ForEach(c => c.IsSupported = _context.SiocCategory.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
            if (!string.IsNullOrEmpty(this.Tags))
            {
                ListTag = JArray.Parse(this.Tags);
            }

            this.Templates = this.Templates ?? ApiTemplateViewModel.Repository.GetModelListBy(
                t => t.Template.Name == ActivedTemplate && t.FolderType == this.TemplateFolderType).Data;
            this.View = Templates.FirstOrDefault(t => !string.IsNullOrEmpty(this.Template) && this.Template.Contains(t.FileName + t.Extension));
            this.View = View ?? Templates.FirstOrDefault();
            if (this.View == null)
            {
                this.View = new ApiTemplateViewModel(new SiocTemplate()
                {
                    Extension    = SWCmsConstants.Parameters.TemplateExtension,
                    TemplateId   = GlobalConfigurationService.Instance.GetLocalInt(SWCmsConstants.ConfigurationKeyword.ThemeId, Specificulture, 0),
                    TemplateName = ActivedTemplate,
                    FolderType   = TemplateFolderType,
                    FileFolder   = this.TemplateFolder,
                    FileName     = SWCmsConstants.Default.DefaultTemplate,
                    ModifiedBy   = ModifiedBy,
                    Content      = "<div></div>"
                });
            }
            this.Template = SwCmsHelper.GetFullPath(new string[]
            {
                this.View?.FileFolder
                , this.View?.FileName
            });

            this.ModuleNavs   = GetModuleNavs(_context, _transaction);
            this.ParentNavs   = GetParentNavs(_context, _transaction);
            this.ChildNavs    = GetChildNavs(_context, _transaction);
            this.PositionNavs = GetPositionNavs(_context, _transaction);
        }
 public SupportedCulture GetCulture(string specificulture)
 {
     return(ListSupportedCulture.Find(c => c.Specificulture == specificulture));
 }
Example #5
0
        public override void ExpandView(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            ListSupportedCulture = CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);
            ListSupportedCulture.ForEach(c => c.IsSupported = _context.SiocProduct.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));

            StrNormalPrice = SwCmsHelper.FormatPrice(NormalPrice);
            StrDealPrice   = SwCmsHelper.FormatPrice(DealPrice);
            StrImportPrice = SwCmsHelper.FormatPrice(ImportPrice);

            if (!string.IsNullOrEmpty(this.Tags))
            {
                ListTag = JArray.Parse(this.Tags);
            }
            Properties = new List <ExtraProperty>();
            if (!string.IsNullOrEmpty(ExtraProperties))
            {
                JArray arr = JArray.Parse(ExtraProperties);
                foreach (JToken item in arr)
                {
                    Properties.Add(item.ToObject <ExtraProperty>());
                }
            }
            //Get Templates
            this.Templates = this.Templates ??
                             BETemplateViewModel.Repository.GetModelListBy(
                t => t.Template.Name == ActivedTemplate && t.FolderType == this.TemplateFolderType).Data;
            if (!string.IsNullOrEmpty(Template))
            {
                this.View = Templates.FirstOrDefault(t => Template.Contains(t.FileName));
            }
            this.View = View ?? Templates.FirstOrDefault();

            if (this.View == null)
            {
                this.View = new BETemplateViewModel(new SiocTemplate()
                {
                    Extension    = SWCmsConstants.Parameters.TemplateExtension,
                    TemplateId   = GlobalConfigurationService.Instance.GetLocalInt(SWCmsConstants.ConfigurationKeyword.ThemeId, Specificulture, 0),
                    TemplateName = ActivedTemplate,
                    FolderType   = TemplateFolderType,
                    FileFolder   = this.TemplateFolder,
                    FileName     = SWCmsConstants.Default.DefaultTemplate,
                    ModifiedBy   = ModifiedBy,
                    Content      = "<div></div>"
                });
            }

            this.Template = SwCmsHelper.GetFullPath(new string[]
            {
                this.View?.FileFolder
                , this.View?.FileName
            });

            var getCateProduct = CommonRepository.Instance.GetCategoryProductNav(Id, Specificulture, _context, _transaction);

            if (getCateProduct.IsSucceed)
            {
                this.Categories = getCateProduct.Data;
                this.Categories.ForEach(c =>
                {
                    c.IsActived = NavCategoryProductViewModel.Repository.CheckIsExists(n => n.CategoryId == c.CategoryId && n.ProductId == Id, _context, _transaction);
                });
            }

            var getModuleProduct = CommonRepository.Instance.GetModuleProductNav(Id, Specificulture, _context, _transaction);

            if (getModuleProduct.IsSucceed)
            {
                this.Modules = getModuleProduct.Data;
            }

            var getProductModule = CommonRepository.Instance.GetProductModuleNav(Id, Specificulture, _context, _transaction);

            if (getProductModule.IsSucceed)
            {
                this.ModuleNavs = getProductModule.Data;
            }

            var getProductMedia = NavProductMediaViewModel.Repository.GetModelListBy(n => n.ProductId == Id && n.Specificulture == Specificulture, _context, _transaction);

            if (getProductMedia.IsSucceed)
            {
                MediaNavs = getProductMedia.Data.OrderBy(p => p.Priority).ToList();
                MediaNavs.ForEach(n => n.IsActived = true);
            }

            var getRelatedProduct = NavRelatedProductViewModel.Repository.GetModelListBy(n => (n.SourceProductId == Id || n.RelatedProductId == Id) && n.Specificulture == Specificulture, _context, _transaction);

            if (getRelatedProduct.IsSucceed)
            {
                ProductNavs = getRelatedProduct.Data.OrderBy(p => p.Priority).ToList();
                ProductNavs.ForEach(n => n.IsActived = true);
            }

            this.ActivedModules = new List <BEModuleViewModel>();
            foreach (var module in this.ModuleNavs.Where(m => m.IsActived))
            {
                var getModule = BEModuleViewModel.Repository.GetSingleModel(m => m.Id == module.ModuleId && m.Specificulture == module.Specificulture, _context, _transaction);
                if (getModule.IsSucceed)
                {
                    this.ActivedModules.Add(getModule.Data);
                    this.ActivedModules.ForEach(m => m.LoadData(Id));
                }
            }
        }
 public override void ExpandView(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
 {
     IsClone = true;
     ListSupportedCulture = CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);
     ListSupportedCulture.ForEach(c => c.IsSupported = _context.SiocUrlAlias.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
 }