コード例 #1
0
ファイル: ProfileViewModel.cs プロジェクト: poutine70/UCR
        public MappingViewModel AddMapping(Mapping mapping)
        {
            var mappingViewModel = new MappingViewModel(this, mapping);

            MappingsList.Add(mappingViewModel);
            return(mappingViewModel);
        }
コード例 #2
0
        public TModel Get <TEntity, TModel>(Expression <Func <TEntity, bool> > filterExpression = null)
            where TEntity : class
        {
            if (MappingsList.Exist <TEntity, TModel>())
            {
                var query = _repository.GetList(filterExpression);
                return(query.AsQuery <TEntity, TModel>().FirstOrDefault());
            }

            var entity = _repository.Get(filterExpression);

            return(entity.To <TModel>());
        }
コード例 #3
0
        public TModel Get <TEntity, TModel>(int id)
            where TEntity : class, IEntity
        {
            if (MappingsList.Exist <TEntity, TModel>())
            {
                var query = _repository.GetQueryById <TEntity>(id);
                return(query.AsQuery <TEntity, TModel>().FirstOrDefault());
            }

            var entity = _repository.Get <TEntity>(id);

            return(entity.To <TModel>());
        }
コード例 #4
0
        public static List <TModel> To <TEntity, TModel>(this IQueryable <TEntity> input)
            where TEntity : class
        {
            if (typeof(TEntity) == typeof(TModel))
            {
                return(input.ToList().Cast <TModel>().ToList());
            }

            if (MappingsList.Exist <TEntity, TModel>())
            {
                return(input.AsQuery <TEntity, TModel>().ToList());
            }

            return(input.ToList().To <TModel>());
        }
コード例 #5
0
ファイル: ProfileViewModel.cs プロジェクト: poutine70/UCR
        public void RemoveMapping(MappingViewModel mappingViewModel)
        {
            if (mappingViewModel.Mapping.DeviceBindings.Count > 0)
            {
                var result =
                    MessageBox.Show("Are you sure you want to remove '" + mappingViewModel.Mapping.Title + "'?",
                                    "Remove mapping?", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            if (Profile.RemoveMapping(mappingViewModel.Mapping))
            {
                MappingsList.Remove(mappingViewModel);
            }
        }
コード例 #6
0
        public async void RemoveMapping(MappingViewModel mappingViewModel)
        {
            if (mappingViewModel.Mapping.DeviceBindings.Count > 0)
            {
                var dialog = new BoolDialog("Remove mapping", "Are you sure you want to remove the mapping: " + mappingViewModel.Mapping.Title + "?");
                var result = (bool?)await DialogHost.Show(dialog, ProfileDialogIdentifier);

                if (result == null || !result.Value)
                {
                    return;
                }
            }

            if (Profile.RemoveMapping(mappingViewModel.Mapping))
            {
                MappingsList.Remove(mappingViewModel);
            }
        }