コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: hva/warehouse.net
        public MainViewModel(IEventAggregator eventAggregator, ISignalRClient signalRClient, IAuthStore authStore,
            IProductsRepository productsRepository)
        {
            this.eventAggregator = eventAggregator;
            this.signalRClient = signalRClient;
            this.productsRepository = productsRepository;

            deleteRequest = new InteractionRequest<Confirmation>();
            CreateProductCommand = new DelegateCommand(CreateProduct);
            OpenProductCommand = new DelegateCommand<Product>(EditProduct);
            changePriceCommand = new DelegateCommand(ChangePrice, HasSelectedProducts);
            deleteCommand = new DelegateCommand(PromtDelete, HasSelectedProducts);

            cvs = new CollectionViewSource();
            items = new ObservableCollection<Product>();
            cvs.Source = items;
            cvs.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            cvs.SortDescriptions.Add(new SortDescription("Size", ListSortDirection.Ascending));

            var token = authStore.LoadToken();
            if (token != null)
            {
                IsEditor = token.IsEditor();
                IsAdmin = token.IsAdmin();
            }
        }
コード例 #2
0
ファイル: BearerHttpClient.cs プロジェクト: hva/warehouse.net
        public BearerHttpClient(IAuthStore authStore, IApplicationSettings settings)
        {
            BaseAddress = new Uri(settings.Endpoint, UriKind.Absolute);

            var token = authStore.LoadToken();
            DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Bearer, token.AccessToken);
        }
コード例 #3
0
ファイル: FilesViewModel.cs プロジェクト: hva/warehouse.net
        public FilesViewModel(IFilesRepository filesRepository, IAuthStore authStore, IProductsRepository productsRepository, 
            Func<CreateFileViewModel> createFactory, Func<EditFileViewModel> editFactory)
        {
            this.filesRepository = filesRepository;
            this.productsRepository = productsRepository;
            this.createFactory = createFactory;
            this.editFactory = editFactory;

            var token = authStore.LoadToken();
            if (token != null)
            {
                IsEditor = token.IsEditor();
                IsAdmin = token.IsAdmin();
            }

            cvs = new CollectionViewSource();
            items = new ObservableCollection<FileDescription>();
            cvs.Source = items;
            cvs.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            cvs.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending));

            editRequest = new InteractionRequest<IConfirmation>();
            BrowseCommand = new DelegateCommand(Browse);
            EditCommand = new DelegateCommand<FileDescription>(Edit);

            deleteCommand = new DelegateCommand(PromtDelete, HasSelectedItems);
            deleteRequest = new InteractionRequest<Confirmation>();
        }
コード例 #4
0
        public SettingsViewModel(IAuthStore authStore, IUsersRepository usersRepository)
        {
            this.usersRepository = usersRepository;

            SaveCommand = new DelegateCommand(Save);

            var token = authStore.LoadToken();
            if (token != null && token.IsAuthenticated())
            {
                UserName = token.UserName;
                Role = token.Role;
            }
        }
コード例 #5
0
        //private readonly AttachmentsViewModel attachmentsViewModel;

        public ProductEditWindowViewModel(IProductsRepository repository, IEventAggregator eventAggregator,
            IAuthStore authStore/*, AttachmentsViewModel attachmentsViewModel*/)
        {
            this.repository = repository;
            this.eventAggregator = eventAggregator;
            //this.attachmentsViewModel = attachmentsViewModel;

            var token = authStore.LoadToken();
            if (token != null)
            {
                canSave = token.IsEditor();
                canEditPrice = token.IsAdmin();
            }

            SaveCommand = new DelegateCommand(Save, () => canSave);
            CancelCommand = new DelegateCommand(() => IsWindowOpen = false);
        }
コード例 #6
0
        public SettingsViewModel(IAuthStore authStore, Func<ChangePasswordViewModel> changePasswordFactory)
        {
            this.changePasswordFactory = changePasswordFactory;

            var v = Assembly.GetEntryAssembly().GetName().Version;
            Version = (v.Build > 0)
                ? string.Join(".", new[] { v.Major, v.Minor, v.Build })
                : string.Join(".", new[] { v.Major, v.Minor });

            changePasswordRequest = new InteractionRequest<IConfirmation>();
            ChangePasswordCommand = new DelegateCommand(ChangePassword);

            var token = authStore.LoadToken();
            if (token != null && token.IsAuthenticated())
            {
                UserName = token.UserName;
                Role = token.Role;
            }
        }