Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        public BearerHttpClient(IAuthStore authStore, IApplicationSettings settings)
        {
            BaseAddress = new Uri(settings.Endpoint, UriKind.Absolute);

            var token = authStore.LoadToken();
            DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Bearer, token.AccessToken);
        }
Exemplo n.º 3
0
        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>();
        }
Exemplo n.º 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;
            }
        }
        //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);
        }
Exemplo n.º 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;
            }
        }