public void LoadReferenceData(string parentId, MixEnums.MixAttributeSetDataType parentType, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { var refFields = Values.Where(m => m.DataType == MixEnums.MixDataType.Reference).OrderBy(v => v.Priority).ToList(); foreach (var item in refFields) { item.Field = item.Field ?? MixAttributeFields.ReadViewModel.Repository.GetSingleModel(m => m.Id == item.AttributeFieldId , _context, _transaction).Data; Expression <Func <MixRelatedAttributeData, bool> > predicate = model => (model.AttributeSetId == item.Field.ReferenceId) && (model.ParentId == parentId && model.ParentType == parentType.ToString()) && model.Specificulture == Specificulture ; var getData = MixRelatedAttributeDatas.NavigationViewModel.Repository.GetModelListBy(predicate, _context, _transaction); JArray arr = new JArray(); foreach (var nav in getData.Data.OrderBy(d => d.Priority)) { nav.Data.Obj.Add(new JProperty("data", nav.Data.Obj)); arr.Add(nav.Data.Obj); } if (Obj.ContainsKey(item.AttributeFieldName)) { Obj[item.AttributeFieldName] = arr; } else { Obj.Add(new JProperty(item.AttributeFieldName, arr)); } } }
public static async Task <RepositoryResponse <AddictionalViewModel> > GetAddictionalData( MixEnums.MixAttributeSetDataType parentType, int parentId, HttpRequest request, string culture = null, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { UnitOfWorkHelper <MixCmsContext> .InitTransaction(_context, _transaction, out MixCmsContext context, out IDbContextTransaction transaction, out bool isRoot); try { // Addictional Data is sub data of page / post / module only culture = culture ?? MixService.GetConfig <string>("DefaultCulture"); var databaseName = request.Query["databaseName"].ToString(); var dataId = (await context.MixRelatedAttributeData.FirstOrDefaultAsync( m => m.AttributeSetName == databaseName && m.ParentType == parentType.ToString() && m.ParentId == parentId.ToString() && m.Specificulture == culture))?.DataId; if (!string.IsNullOrEmpty(dataId)) { return(await AddictionalViewModel.Repository.GetSingleModelAsync( m => m.Id == dataId && m.Specificulture == culture)); } else { // Init default data var getAttrSet = await Lib.ViewModels.MixAttributeSets.UpdateViewModel.Repository.GetSingleModelAsync( m => m.Name == request.Query["databaseName"].ToString()); if (getAttrSet.IsSucceed) { AddictionalViewModel result = new AddictionalViewModel() { Specificulture = culture, AttributeSetId = getAttrSet.Data.Id, AttributeSetName = getAttrSet.Data.Name, Status = MixEnums.MixContentStatus.Published, Fields = getAttrSet.Data.Fields, ParentType = parentType }; result.ExpandView(); return(new RepositoryResponse <AddictionalViewModel>() { IsSucceed = true, Data = result }); } } return(new RepositoryResponse <AddictionalViewModel>()); } catch (Exception ex) { return(UnitOfWorkHelper <MixCmsContext> .HandleException <AddictionalViewModel>(ex, isRoot, transaction)); } finally { if (isRoot) { //if current Context is Root UnitOfWorkHelper <MixCmsContext> .CloseDbContext(ref context, ref transaction); } } }
private void GetAdditionalData(string id, MixEnums.MixAttributeSetDataType type, MixCmsContext context, IDbContextTransaction transaction) { V_0 = new SiteStructureViewModel.u003cu003ec__DisplayClass51_0(); V_0.id = id; V_0.type = type; V_0.u003cu003e4__this = this; if (!this.get_RelatedData().Any<Mix.Cms.Lib.ViewModels.MixRelatedAttributeDatas.ImportViewModel>(new Func<Mix.Cms.Lib.ViewModels.MixRelatedAttributeDatas.ImportViewModel, bool>(V_0.u003cGetAdditionalDatau003eb__0))) { stackVariable13 = ViewModelBase<MixCmsContext, MixRelatedAttributeData, Mix.Cms.Lib.ViewModels.MixRelatedAttributeDatas.ImportViewModel>.Repository; V_2 = Expression.Parameter(Type.GetTypeFromHandle(//
private void GetAdditionalData(string id, MixEnums.MixAttributeSetDataType type, MixCmsContext context, IDbContextTransaction transaction) { var getRelatedData = MixRelatedAttributeDatas.ImportViewModel.Repository.GetSingleModel( m => m.Specificulture == Specificulture && m.ParentType == type.ToString() && m.ParentId == id, context, transaction); if (getRelatedData.IsSucceed) { RelatedData = (getRelatedData.Data); } }
public void LoadData(string parentId, MixEnums.MixAttributeSetDataType parentType, string specificulture, int?pageSize = null, int?pageIndex = 0 , MixCmsContext _context = null, IDbContextTransaction _transaction = null) { var getData = MixRelatedAttributeDatas.ReadMvcViewModel.Repository .GetModelListBy( m => m.ParentId == parentId && m.ParentType == (int)parentType && m.Specificulture == specificulture , MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.OrderBy), 0 , pageSize, pageIndex , _context: _context, _transaction: _transaction); Data = getData.Data; }
public static async Task <RepositoryResponse <PaginationModel <TView> > > GetAttributeDataByParent <TView>( string culture, string attributeSetName, string parentId, MixEnums.MixAttributeSetDataType parentType, string orderBy = "CreatedDateTime", Heart.Enums.MixHeartEnums.DisplayDirection direction = MixHeartEnums.DisplayDirection.Desc, int?pageSize = null, int?pageIndex = 0, MixCmsContext _context = null, IDbContextTransaction _transaction = null) where TView : ViewModelBase <MixCmsContext, MixAttributeSetData, TView> { return(await ViewModels.MixAttributeSetDatas.Helper.GetAttributeDataByParent <TView>( culture, attributeSetName, parentId, parentType, orderBy, direction, pageSize, pageIndex, _context, _transaction)); }
public static async Task <RepositoryResponse <List <MixRelatedAttributeData> > > RemoveRelatedDataAsync( string parentId, MixEnums.MixAttributeSetDataType parentType, string specificulture , MixCmsContext context, IDbContextTransaction transaction) { var result = await MixRelatedAttributeDatas.DeleteViewModel.Repository.RemoveListModelAsync( true , a => a.ParentId == parentId && a.ParentType == parentType.ToString() && a.Specificulture == specificulture , context, transaction); return(result); }
V_0 = Expression.Parameter(System.Type.GetTypeFromHandle(// // Current member / type: System.Void Mix.Cms.Lib.ViewModels.MixAttributeSets.ReadMvcViewModel::ExpandView(Mix.Cms.Lib.Models.Cms.MixCmsContext,Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction) // Exception in: System.Void ExpandView(Mix.Cms.Lib.Models.Cms.MixCmsContext,Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction) // Specified method is not supported. // // mailto: [email protected] public void LoadData(string parentId, MixEnums.MixAttributeSetDataType parentType, string specificulture, int? pageSize = null, int? pageIndex = 0, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { V_0 = new Mix.Cms.Lib.ViewModels.MixAttributeSets.ReadMvcViewModel.u003cu003ec__DisplayClass79_0(); V_0.parentId = parentId; V_0.parentType = parentType; V_0.specificulture = specificulture; stackVariable7 = ViewModelBase<MixCmsContext, MixRelatedAttributeData, Mix.Cms.Lib.ViewModels.MixRelatedAttributeDatas.ReadMvcViewModel>.Repository; V_2 = Expression.Parameter(System.Type.GetTypeFromHandle(// // Current member / type: System.Void Mix.Cms.Lib.ViewModels.MixAttributeSets.ReadMvcViewModel::LoadData(System.String,Mix.Cms.Lib.MixEnums/MixAttributeSetDataType,System.String,System.Nullable`1<System.Int32>,System.Nullable`1<System.Int32>,Mix.Cms.Lib.Models.Cms.MixCmsContext,Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction) // Exception in: System.Void LoadData(System.String,Mix.Cms.Lib.MixEnums/MixAttributeSetDataType,System.String,System.Nullable<System.Int32>,System.Nullable<System.Int32>,Mix.Cms.Lib.Models.Cms.MixCmsContext,Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction) // Specified method is not supported. // // mailto: [email protected] }
public static async Task <RepositoryResponse <PaginationModel <TView> > > GetAttributeDataByParent <TView>( string culture, string attributeSetName, string parentId, MixEnums.MixAttributeSetDataType parentType, string orderBy, Heart.Enums.MixHeartEnums.DisplayDirection direction, int?pageSize, int?pageIndex, MixCmsContext _context = null, IDbContextTransaction _transaction = null) where TView : ViewModelBase <MixCmsContext, MixAttributeSetData, TView> { UnitOfWorkHelper <MixCmsContext> .InitTransaction(_context, _transaction, out MixCmsContext context, out IDbContextTransaction transaction, out bool isRoot); try { var tasks = new List <Task <RepositoryResponse <TView> > >(); Expression <Func <MixRelatedAttributeData, bool> > predicate = m => m.Specificulture == culture && (m.AttributeSetName == attributeSetName) && (m.Status == MixEnums.MixContentStatus.Published.ToString()) && (string.IsNullOrEmpty(parentId) || (m.ParentId == parentId && m.ParentType == parentType.ToString()) ); ; var query = context.MixRelatedAttributeData.Where(predicate).Select(m => m.DataId).Distinct(); var dataIds = query.ToList(); Expression <Func <MixAttributeSetData, bool> > pre = m => dataIds.Any(id => m.Id == id); return(await DefaultRepository <MixCmsContext, MixAttributeSetData, TView> .Instance.GetModelListByAsync( pre, orderBy, direction, pageSize, pageIndex, null, null, context, transaction)); } catch (Exception ex) { return(UnitOfWorkHelper <MixCmsContext> .HandleException <PaginationModel <TView> >(ex, isRoot, transaction)); } finally { if (isRoot) { //if current Context is Root context.Database.CloseConnection(); transaction.Dispose(); context.Dispose(); } } }
private void GetAdditionalData(string id, MixEnums.MixAttributeSetDataType type, MixCmsContext context, IDbContextTransaction transaction) { var getRelatedData = MixRelatedAttributeDatas.ReadViewModel.Repository.GetSingleModel( m => m.Specificulture == Specificulture && m.ParentType == (int)type && m.ParentId == id, context, transaction); if (getRelatedData.IsSucceed) { RelatedData.Add(getRelatedData.Data); var getData = MixAttributeSetDatas.ImportViewModel.Repository.GetSingleModel( m => m.Specificulture == Specificulture && m.Id == getRelatedData.Data.Id); if (getData.IsSucceed) { getData.Data.Fields = new List <MixAttributeFields.UpdateViewModel>(); foreach (var item in getData.Data.Values) { getData.Data.Fields.Add(item.Field); } AttributeSetDatas.Add(getData.Data); } } }
public async Task <ActionResult <List <Lib.ViewModels.MixAttributeSetDatas.ReadMvcViewModel> > > ListDataByParent(string culture, MixEnums.MixAttributeSetDataType parentType, string parentId, int?attributeSetId, ODataQueryOptions <MixRelatedAttributeData> queryOptions) { var data = new List <Lib.ViewModels.MixAttributeSetDatas.ReadMvcViewModel>(); var arr = new JArray(); Expression <Func <MixRelatedAttributeData, bool> > predicate = null; if (attributeSetId.HasValue) { predicate = m => m.ParentType == (int)parentType && m.ParentId == parentId && m.AttributeSetId == attributeSetId; } else { predicate = m => m.ParentType == (int)parentType && m.ParentId == parentId; } var result = await base.GetListAsync <ReadMvcViewModel>(predicate, $"parent_{parentType}_{parentId}_{attributeSetId}", queryOptions); if (result != null) { foreach (var item in result) { data.Add(item.Data); arr.Add(item.Data.Data); } } return(Ok(arr)); }