Exemplo n.º 1
0
        public async Task <IActionResult> Index(string system = SolarSystemId.Jita)
        {
            AuthDTO auth;

            try
            {
                auth = User.GetAuth();
            }
            catch (UnauthorizedAccessException)
            {
                return(Content("You must auth with eve online."));
            }

            //Grab bookmarks
            var personalBookmarkSection = await GetPersonalBookmarkSection(int.Parse(system));

            var universeIds = GetIdsForCaching(personalBookmarkSection);

            var corporationBookmarkSection = await GetCorporationBookmarkSection(int.Parse(system));

            universeIds.AddRange(GetIdsForCaching(corporationBookmarkSection));

            //Query ESI for real name
            await _universeCache.PopulateIdCache(universeIds.Distinct());

            await SubmitSystemsToRouteCache(personalBookmarkSection, int.Parse(system));
            await SubmitSystemsToRouteCache(corporationBookmarkSection, int.Parse(system));

            var viewModel = new BookmarkViewModel(personalBookmarkSection, corporationBookmarkSection, system, _provider.GetService <IStaticDataRepository>());

            return(View(viewModel));
        }
Exemplo n.º 2
0
 protected override async Task DoExecute()
 {
     Debug.WriteLine("正在删除数据");
     BookmarkViewModel current  = this.ViewModel.CurrentSelected;
     Bookmark          bookmark = ObjectMapper.Map <BookmarkViewModel, Bookmark>(current);
     await BookmarkService.Delete(bookmark);
 }
        public HttpResponseMessage SaveBookmark(BookmarkViewModel bookmarkViewModel)
        {
            try
            {
                var b        = bookmarkViewModel;
                var userId   = UserController.Instance.GetCurrentUserInfo().UserID;
                var portalId = PortalSettings.PortalId;
                var id       = BookmarksRepository.Instance.SaveBookmark(new Bookmark(b, userId, portalId));
                if (id > -1)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        Success = true,
                        Data = id
                    }));
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, new
                {
                    Success = false
                }));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, new
                {
                    Success = false,
                    Error = e
                }));
            }
        }
        private void ModifyBookmarkWindow_Loaded(object sender, RoutedEventArgs e)
        {
            BookmarkViewModel bookmarkViewModel = this.DoBookmarkGridViewModel.CurrentSelected;
            BookmarkModel     bookmarkModel     = ObjectMapper.Map <BookmarkViewModel, BookmarkModel>(bookmarkViewModel);

            this.DataContext = bookmarkModel;
        }
        public async Task <ActionResult> Delete(Guid id)
        {
            HttpRequestMessage apiRequest = CreateRequestToService(HttpMethod.Get, $"Bookmarks/{id}");

            HttpResponseMessage apiResponse;

            try
            {
                apiResponse = await HttpClient.SendAsync(apiRequest);
            }
            catch
            {
                return(RedirectToAction("Details", id));
            }

            if (!apiResponse.IsSuccessStatusCode)
            {
                return(RedirectToAction("Details", id));
            }

            BookmarkViewModel bm = await apiResponse.Content.ReadAsAsync <BookmarkViewModel>();

            PassCookiesToClient(apiResponse);

            var user = await WhoAmI();

            if (bm.Collection.OwnerId != user.Id)
            {
                TempData["Message"] = "Please log in.";
                return(RedirectToAction("Login", "Accounts"));
            }

            return(View(bm));
        }
Exemplo n.º 6
0
        private void Append()
        {
            // create header as html
            var headerHtml = new HtmlDocument();
            var domain     = new Uri(BookmarkViewModel.Url).Host;

            headerHtml.LoadHtml(string.Format("<h2>{0}</h2><p>{1}</p>", BookmarkViewModel.Title, domain));

            _textBoxes = new List <RichTextBox>();
            _itemsControl.Items.Clear();

            AddTextBox(null, topMargin: 15, bottomMargin: 0);
            AddParagraph();
            AppendSpan(headerHtml.DocumentNode.ChildNodes[0], _currentParagraph, null, "title");
            AddTextBox(null, bottomMargin: 0);
            AddParagraph();
            AppendSpan(headerHtml.DocumentNode.ChildNodes[1], _currentParagraph, null, "p");

            //RenderBody(headerHtml.DocumentNode);

            var bodyHtml = new HtmlDocument();
            var body     = BookmarkViewModel.GetBodyFromStorage();

            body = StripWhitespaceFromBody(body);
            bodyHtml.LoadHtml(body);

            RenderBody(bodyHtml.DocumentNode);
        }
Exemplo n.º 7
0
        private void EditBookmark(BookmarkViewModel bookmarkViewModel)
        {
            var bookmarkClone =
                _tempApplicationData.Bookmarks.First(b => b.Name.Equals(bookmarkViewModel.BookmarkName)).Clone();
            var viewModelCopy = new BookmarkViewModel(bookmarkClone);

            _bookmarkWindow = new BookmarkSettingsWindow();

            //TODO: validate settings
            viewModelCopy.BrowseCommand = new RelayCommand <string>(s =>
            {
                var newPath = ShowVagrantFolderBrowser(_bookmarkWindow, s);
                if (!newPath.Equals(String.Empty))
                {
                    viewModelCopy.VagrantInstanceLocation = newPath;
                }
            });
            viewModelCopy.SaveCommand = new RelayCommand(() =>
            {
                bookmarkViewModel.BookmarkName            = viewModelCopy.BookmarkName;
                bookmarkViewModel.VagrantInstanceLocation = viewModelCopy.VagrantInstanceLocation;
                DestroyBookmarkWindow();
            });
            viewModelCopy.CancelCommand = new RelayCommand(DestroyBookmarkWindow);

            _bookmarkWindow.DataContext = viewModelCopy;

            _bookmarkWindow.Show();
            _bookmarkWindow.Activate();
        }
        public IActionResult Put(int id, [FromBody] BookmarkViewModel bookmarkViewModel)
        {
            if (ModelState.IsValid)
            {
                var bookmark = _context.Bookmark.SingleOrDefault(b => b.Id == id);

                if (bookmark == null)
                {
                    return(NotFound());
                }
                else
                {
                    bookmark.Name = bookmarkViewModel.Name;
                    bookmark.Url  = bookmarkViewModel.Url;

                    _context.SaveChanges();

                    return(Ok());
                }
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
        public async Task <ActionResult> New(BookmarkViewModel bookmark)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("CollectionDetails", "Collections", new { id = bookmark.CollectionId }));
            }

            HttpRequestMessage apiRequest = CreateRequestToService(HttpMethod.Post, "Bookmarks");

            apiRequest.Content = new ObjectContent <BookmarkViewModel>(bookmark, new JsonMediaTypeFormatter());

            HttpResponseMessage apiResponse;

            try
            {
                apiResponse = await HttpClient.SendAsync(apiRequest);
            }
            catch
            {
                return(RedirectToAction("CollectionDetails", "Collections", new { id = bookmark.CollectionId }));
            }

            if (!apiResponse.IsSuccessStatusCode)
            {
                return(RedirectToAction("CollectionDetails", "Collections", new { id = bookmark.CollectionId }));
            }

            PassCookiesToClient(apiResponse);
            return(RedirectToAction("CollectionDetails", "Collections", new { id = bookmark.CollectionId }));
        }
Exemplo n.º 10
0
        public BookmarkPage(Category category)
        {
            InitializeComponent();

            BindingContext = viewModel = new BookmarkViewModel(category);

            this.Title = category.Name + " (" + category.Progress + ")";
        }
Exemplo n.º 11
0
            protected override void DoSuccess()
            {
                Debug.WriteLine("正在移除数据");
                BookmarkViewModel current = this.ViewModel.CurrentSelected;

                this.ViewModel.Data.Remove(current);
                Debug.WriteLine("移除结束");
            }
        public async Task <ActionResult> New(Guid collectionId)
        {
            var user = await WhoAmI();

            BookmarkViewModel bm = new BookmarkViewModel();

            bm.CollectionId = collectionId;
            return(View(bm));
        }
Exemplo n.º 13
0
        public IActionResult Create()
        {
            var viewModel = new BookmarkViewModel
            {
                Categories = _categoryService.GetCategories()
            };

            return(View("BookmarksForm", viewModel));
        }
Exemplo n.º 14
0
        private void Hyperlink_Click(object sender, RoutedEventArgs e)
        {
            BookmarkViewModel bookmarkView = this.ViewModel.CurrentSelected;

            if (bookmarkView != null)
            {
                System.Diagnostics.Process.Start(bookmarkView.Url);
            }
        }
Exemplo n.º 15
0
        public void TestMergedDataSource()
        {
            var dataSource = new Mock <IMergedDataSource>();

            dataSource.SetupGet(x => x.DisplayName).Returns("My Merged Data Source");
            var bookmark  = new Bookmark(dataSource.Object, 9001);
            var viewModel = new BookmarkViewModel(bookmark, model => {}, model => {});

            viewModel.Name.Should().Be("Line #9002, My Merged Data Source");
        }
Exemplo n.º 16
0
        public void TestDataSource()
        {
            var dataSource = new Mock <IDataSource>();

            dataSource.SetupGet(x => x.FullFileName).Returns("C:\\my_awesome_log_file.txt");
            var bookmark  = new Bookmark(dataSource.Object, 9001);
            var viewModel = new BookmarkViewModel(bookmark, model => {}, model => {});

            viewModel.Name.Should().Be("Line #9002, my_awesome_log_file.txt");
        }
Exemplo n.º 17
0
        internal EditBookmark(BookmarkViewModel viewModel)
        {
            if (viewModel is null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            InitializeComponent();

            DataContext = viewModel;
        }
        public ActionResult Create([Bind(Include = "Id,Name,Url,ThumbnailUrl")] BookmarkViewModel createBookmarkViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(createBookmarkViewModel));
            }

            bookmarkService.CreateBookmark(createBookmarkViewModel.Name, createBookmarkViewModel.Url, createBookmarkViewModel.ThumbnailUrl);

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "Id,Name,Url,ThumbnailUrl")] BookmarkViewModel editViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(editViewModel));
            }

            bookmarkService.EditBookmark(editViewModel.Id, editViewModel.Name, editViewModel.Url);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 20
0
        public ActionResult Create()
        {
            var listArticles = _context.Articles.GetAll();
            var listUsers    = _entities.AspNetUsers.ToList();
            var viewModel    = new BookmarkViewModel
            {
                Authors  = new SelectList(listUsers, "Id", "UserName"),
                Articles = new SelectList(listArticles, "Id", "Title")
            };

            return(View(viewModel));
        }
Exemplo n.º 21
0
        public IViewComponentResult Invoke(int productId, string userId, int amount)
        {
            var bookmarks = _context.Bookmarks.Where(b => b.UserId == userId && b.ProductId == productId).ToList();

            var bookmarkstatus = new BookmarkViewModel {
                Bookmarks      = bookmarks,
                currentProduct = productId,
                productAmount  = amount
            };

            return(View(bookmarkstatus));
        }
Exemplo n.º 22
0
 public BookmarkPage()
 {
     InitializeComponent();
     BindingContext = new BookmarkViewModel()
     {
         Navigation = this.Navigation
     };
     BindingContext = new XamlCommands()
     {
         Navigation = this.Navigation
     };
 }
Exemplo n.º 23
0
        public async Task <IActionResult> Save(BookmarkViewModel viewModel)
        {
            var bookmark = new Bookmark
            {
                URL = viewModel.URL,
                ShortDescription = viewModel.ShortDescription,
                CategoryId       = viewModel.CategoryId,
                CreateDate       = DateTime.Now
            };
            await _mediator.Send(new CreateBookmark.Command(bookmark));

            return(RedirectToAction("Index"));
        }
Exemplo n.º 24
0
        private void DeleteBookmark(BookmarkViewModel bookmarkViewModel)
        {
            var result = MessageBox.Show(new Win32Wrapper(_settingsWindow), "Are you sure you want to delete this bookmark?",
                                         "Delete Bookmark", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            _tempApplicationData.Bookmarks.Remove(
                _tempApplicationData.Bookmarks.First(b => b.Name == bookmarkViewModel.BookmarkName));
        }
Exemplo n.º 25
0
            protected override bool DoBefore()
            {
                BookmarkViewModel current = this.ViewModel.CurrentSelected;

                if (MessageBox.Show($"将要删除书签:{current.Title} ,确认操作吗?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.Yes)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
Exemplo n.º 26
0
            protected override void DoExecute()
            {
                ModifyBookmarkWindow window = new ModifyBookmarkWindow();

                window.DoBookmarkGridViewModel = this.ViewModel;
                window.Owner = View.GetWindow();
                if (window.ShowDialog() == true)
                {
                    BookmarkViewModel current = this.ViewModel.CurrentSelected;
                    ObjectMapper.CopyValues <BookmarkViewModel, BookmarkViewModel>(this.ViewModel.DoBookmarkViewModel, current);
                    this.ViewModel.CurrentSelected = this.ViewModel.CurrentSelected;
                }
            }
Exemplo n.º 27
0
        public ActionResult Edits(BookmarkViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }
            var bookmark = _context.Bookmarks.Get(viewModel.Id);

            bookmark.ArticleId = viewModel.ArticleId;
            bookmark.UserId    = viewModel.AuthorId;
            _context.Bookmarks.Update(bookmark);
            _context.Complete();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 28
0
        private void AppendBody()
        {
            var html   = new HtmlDocument();
            var domain = new Uri(BookmarkViewModel.Url).Host;

            html.LoadHtml(string.Format("<div><h1>{0}</h1><p>{1}</p></div>", BookmarkViewModel.Title, domain));

            textBoxes = new List <RichTextBox>();
            internalItemsControl.Items.Clear();

            AppendRichtextBox(html.DocumentNode);

            AppendHtml(BookmarkViewModel.GetBodyFromStorage());
        }
Exemplo n.º 29
0
        public ActionResult Edits(String id)
        {
            var bookmark     = _context.Bookmarks.Get(id);
            var listArticles = _context.Articles.GetAll();
            var listUsers    = _entities.AspNetUsers.ToList();
            var viewModel    = new BookmarkViewModel
            {
                Authors   = new SelectList(listUsers, "Id", "UserName"),
                Articles  = new SelectList(listArticles, "Id", "Title"),
                ArticleId = bookmark.ArticleId,
                AuthorId  = bookmark.UserId
            };

            return(View(viewModel));
        }
Exemplo n.º 30
0
 protected override void DoExecute()
 {
     if (this.View.grid.SelectedItems != null)
     {
         ClipboardData data = new ClipboardData();
         data.CatalogId = this.ViewModel.CurrentCatalogModel.Id;
         foreach (var item in this.View.grid.SelectedItems)
         {
             BookmarkViewModel bookmark = item as BookmarkViewModel;
             if (bookmark != null)
             {
                 data.BookmarkList.Add(bookmark.Id);
             }
         }
         Clipboard.SetDataObject(data);
     }
 }
Exemplo n.º 31
0
        /// <summary>
        /// This removes an item from the view model and local storage without actually calling the API.
        /// </summary>
        public void RemoveItem(BookmarkViewModel bookmarkViewModel, SortedObservableCollection<BookmarkViewModel> bookmarksCollection)
        {
            var bookmarkToDelete = bookmarksCollection.Where(b => b.BookmarkId == bookmarkViewModel.BookmarkId).FirstOrDefault();
            if (bookmarkToDelete != null)
                bookmarksCollection.Remove(bookmarkToDelete);

            var bookmarkDbItem = App.DbDataContext.Bookmarks.Where(b => b.BookmarkId == bookmarkViewModel.BookmarkId).FirstOrDefault();
            if (bookmarkDbItem != null)
            {
                App.DbDataContext.Bookmarks.DeleteOnSubmit(bookmarkDbItem);
                App.DbDataContext.SubmitChanges();
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData()
        {
            this.IsLoading = true;

            var bookmarks = App.DbDataContext.Bookmarks.ToList();
            UpdateBookmarkCacheStatus();

            foreach (var bookmark in bookmarks)
            {
                var bookmarkViewModel = new BookmarkViewModel(bookmark);

                SortedObservableCollection<BookmarkViewModel> bookmarksCollection;
                if (bookmark.Folder == "archive")
                    bookmarksCollection = ArchivedBookmarks;
                else if (bookmark.Folder == "starred")
                    bookmarksCollection = StarredBookmarks;
                else
                    bookmarksCollection = Bookmarks;

                var existingBookmark = bookmarksCollection.FirstOrDefault(b => b.BookmarkId == bookmark.BookmarkId);

                if (existingBookmark == null) // new bookmark
                {
                    bookmarksCollection.Add(bookmarkViewModel);
                }
            }

            this.IsLoading = false;
        }
Exemplo n.º 33
0
        private void UpdateBookmarksWithData(IEnumerable<Bookmark> newBookmarks)
        {
            SortedObservableCollection<BookmarkViewModel> bookmarksCollection;

            var firstBookmark = newBookmarks.FirstOrDefault();

            if (firstBookmark == null)
                return;
            else if (firstBookmark.Folder == "archive")
                bookmarksCollection = ArchivedBookmarks;
            else if (firstBookmark.Folder == "starred")
                bookmarksCollection = StarredBookmarks;
            else
                bookmarksCollection = Bookmarks;

            foreach (var bookmark in newBookmarks)
            {
                var bookmarkViewModel = new BookmarkViewModel(bookmark);

                var existingBookmark = bookmarksCollection.FirstOrDefault(b => b.BookmarkId == bookmark.BookmarkId);

                if (existingBookmark == null) // new bookmark
                {
                    try
                    {
                        bookmarksCollection.Add(bookmarkViewModel);
                        App.DbDataContext.Bookmarks.InsertOnSubmit(bookmark);
                    }
                    catch (InvalidOperationException e)
                    {
                        // probably trying to insert dulpicate item
                        continue;
                    }
                }
                else
                {
                    if (bookmark.Hash != existingBookmark.Hash)
                    {
                        // if hash doesn't match, clear the body and description
                        BookmarksStorageManager.DeleteBookmarkCache(bookmark.BookmarkId);
                        bookmark.ShortBodyText = "Downloading...";
                        bookmarkViewModel.IsDownloaded = false;
                    }
                }
            }

            // delete any items that have been removed from the api
            foreach (var existingBookmark in bookmarksCollection.ToList())
            {
                if (newBookmarks.Count(b => b.BookmarkId == existingBookmark.BookmarkId) == 0)
                {
                    RemoveItem(existingBookmark, bookmarksCollection);
                }
            }

            App.DbDataContext.SubmitChanges();
        }
Exemplo n.º 34
0
        private void ShowBookmarkNotDownloaded(BookmarkViewModel bookmarkViewModel)
        {
            var bookmark = App.DbDataContext.Bookmarks.Where(b => b.BookmarkId == bookmarkViewModel.BookmarkId).Single();

            bookmarkViewModel.IsDownloaded = false;
            bookmarkViewModel.Description = "Downloading...";
            App.DbDataContext.SubmitChanges();

            MessageBox.Show("This bookmark is not downloaded", "Please wait for the download to complete, or retry by pressing the refresh button", MessageBoxButton.OK);
        }
Exemplo n.º 35
0
 /// <summary>
 /// Provides a deterministic way to create the bookmark property.
 /// </summary>
 public static void CreateBookmark()
 {
     if (_bookmarkViewModel == null)
     {
         _bookmarkViewModel = new BookmarkViewModel();
     }
 }
Exemplo n.º 36
0
 /// <summary>
 /// Provides a deterministic way to delete the bookmark property.
 /// </summary>
 public static void ClearBookmark()
 {
     if (_bookmarkViewModel != null)
         _bookmarkViewModel.Cleanup();
     _bookmarkViewModel = null;
 }
Exemplo n.º 37
0
        public void RemoveItem(BookmarkViewModel bookmarkViewModel)
        {
            SortedObservableCollection<BookmarkViewModel> bookmarksCollection;

            if (bookmarkViewModel.Folder == "archive")
                bookmarksCollection = ArchivedBookmarks;
            else if (bookmarkViewModel.Folder == "starred")
                bookmarksCollection = StarredBookmarks;
            else
                bookmarksCollection = Bookmarks;

            RemoveItem(bookmarkViewModel, bookmarksCollection);
        }