public override VmFilteredTreeItem TranslateEntityToVm(IFintoItem entity)
        {
            var model = CreateEntityViewModelDefinition(entity)
                        .AddPartial <IFintoItemBase, VmListItem>(i => i, o => o)
                        .AddSimple(i => !i.Children.Any(), o => o.IsLeaf)
                        .AddSimple(i => true, o => o.AreChildrenLoaded)
                        .GetFinal();

            model.Children = entity.Children.Select(input =>
                                                    entityTranslationManager.Translate <IFintoItem, VmFilteredTreeItem>(input as IFintoItem) as IVmTreeItem).OrderBy(x => x.Name).ToList();
            return(model);
        }
示例#2
0
        public IVmListItem GetMunicipalityByCode(string code, bool onlyValid = false)
        {
            var result = new VmListItem();

            contextManager.ExecuteReader(unitOfWork =>
            {
                var rep = unitOfWork.CreateRepository <IMunicipalityRepository>();
                var municipalityCodeQry = rep.All().Where(x => x.Code == code);
                if (onlyValid)
                {
                    municipalityCodeQry = municipalityCodeQry.Where(m => m.IsValid);
                }
                var municipalityCode = municipalityCodeQry.FirstOrDefault();
                if (municipalityCode != null)
                {
                    result = translationEntToVm.Translate <Municipality, VmListItem>(municipalityCode);
                }
            });

            return(result);
        }