private void LastReadSection_Clicked(object sender, object e)
        {
            HistoryItemViewModel item = (sender as FrameworkElement).DataContext as HistoryItemViewModel;

            //e.Handled = true;
            this.Frame.Navigate(typeof(ReadingPage), item.Position.ToString());
        }
        private async void LastReadSection_Clicked(object sender, object e)
        {
            HistoryItemViewModel item = (sender as FrameworkElement).DataContext as HistoryItemViewModel;

            //e.Handled = true;
            //this.Frame.Navigate(typeof(ReadingPage), item.Position.ToString());
            await NavigateToReadingPageAsync(item.SeriesTitle, item.Position);
        }
        private async void RecentItem_Click(object sender, ItemClickEventArgs e)
        {
            HistoryItemViewModel item = (HistoryItemViewModel)e.ClickedItem;

            await NavigateToReadingPageAsync(item.SeriesTitle, item.Position);

            //this.Frame.Navigate(typeof(ReadingPage), item.Position.ToString());
        }
示例#4
0
        public IActionResult AddHistoryItem([FromBody] HistoryItemViewModel vm)
        {
            var studentId = int.Parse(User.Claims.Single(c => c.Type == "sid").Value);

            historyService.AddHistoryItem(vm, studentId);

            return(Ok());
        }
示例#5
0
        public async Task <IActionResult> History(int page = 1)
        {
            int take    = 15;
            int skip    = take * (page - 1);
            var history = await _userService
                          .GetPaginatedUserHistoryAsync(GetActiveUserId(), skip, take);

            PaginateViewModel paginateModel = new PaginateViewModel()
            {
                ItemCount    = history.Count,
                CurrentPage  = page,
                ItemsPerPage = take
            };

            if (paginateModel.MaxPage > 0 && paginateModel.CurrentPage > paginateModel.MaxPage)
            {
                return(RedirectToRoute(
                           new
                {
                    page = paginateModel.LastPage ?? 1
                }));
            }

            User user = await _userService.GetDetails(GetActiveUserId());

            HistoryListViewModel viewModel = new HistoryListViewModel()
            {
                Historys       = new List <HistoryItemViewModel>(),
                PaginateModel  = paginateModel,
                HouseholdCount = await _userService
                                 .FamilyMemberCountAsync(user.HouseholdHeadUserId ?? user.Id),
                HasAccount  = !string.IsNullOrWhiteSpace(user.Username),
                TotalPoints = user.PointsEarned
            };

            foreach (var item in history.Data)
            {
                if (item.ChallengeId != null)
                {
                    var url = Url.Action("Detail", "Challenges", new { id = item.ChallengeId });
                    item.Description = $"<a target='_blank' href='{url}'>{item.Description}</a>";
                }
                HistoryItemViewModel itemModel = new HistoryItemViewModel()
                {
                    CreatedAt    = item.CreatedAt.ToString("d"),
                    Description  = item.Description,
                    PointsEarned = item.PointsEarned,
                };
                if (!string.IsNullOrWhiteSpace(item.BadgeFilename))
                {
                    itemModel.BadgeFilename = _pathResolver.ResolveContentPath(item.BadgeFilename);
                }
                viewModel.Historys.Add(itemModel);
            }
            return(View(viewModel));
        }
        public HistoryListAdapter(Activity activity, HistoryItemViewModel historyItemViewModel)
        {
            this.activity             = activity;
            this.historyItemViewModel = historyItemViewModel;

            this.historyItemViewModel.Items.CollectionChanged += (sender, args) =>
            {
                this.activity.RunOnUiThread(NotifyDataSetChanged);
            };
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
            ViewModel = new HistoryItemViewModel(new ServiceLocator().GetDatabaseHelper);

            _view             = inflater.Inflate(Resource.Layout.history_page_layout, null);
            _listview         = (ListView)_view.FindViewById(Resource.Id.history_list_view);
            _progressBar      = (ProgressBar)_view.FindViewById(Resource.Id.loading_bar);
            _adapter          = new HistoryListAdapter(Activity, ViewModel);
            _listview.Adapter = _adapter;
            return(_view);
        }
        private async Task RemoveRecentItem(HistoryItemViewModel hvm)
        {
            ViewModel.IsLoading = true;
            await CachedClient.DeleteSeries(hvm.Position.SeriesId);

            ViewModel.RecentSection.Remove(hvm);
            var recentItem = AppGlobal.RecentList.FirstOrDefault(it => it.Position.SeriesId == hvm.Position.SeriesId);

            if (recentItem != null)
            {
                AppGlobal.RecentList.Remove(recentItem);
                await AppGlobal.SaveHistoryDataAsync();
            }
            ViewModel.IsLoading = false;
        }
示例#9
0
        void OnHistoryItemClicked(HistoryItemViewModel e)
        {
            int tokenSize;

            Debug.Assert(e.GetTokens() != null);
            e.GetTokens().GetSize(out tokenSize);
            // TraceLogger.GetInstance().LogHistoryItemLoadBegin();
            Model.SetHistoryExpressionDisplay(e.GetTokens(), e.GetCommands());
            Model.SetExpressionDisplay(e.GetTokens(), e.GetCommands());
            Model.SetPrimaryDisplay(e.Result, false);
            Model.IsFToEEnabled = false;

            // TraceLogger.GetInstance().LogHistoryItemLoadEnd(tokenSize);
            CloseHistoryFlyout();
            this.Focus(FocusState.Programmatic);
        }
示例#10
0
        public override Task <List <HistoryItemViewModel> > GenerateHistoryItemViewModelsAsync(GetHistoryListResponse response)
        {
            return(Task.Factory.StartNew(() =>
            {
                var historyItemViewModels = response.Results
                                            .Select((x, i) =>
                {
                    var item = new HistoryItemViewModel();
                    item.Name = "Instance " + item.Name;

                    return item;
                })
                                            .ToList();
                return new List <HistoryItemViewModel>(historyItemViewModels);
            }, _scheduler.Task.TPL));
        }
示例#11
0
        private void AddHistoryItem(HistoryItemViewModel model)
        {
            MethodInvoker methodInvokerDelegate = delegate
            {
                HistoryListBox.Items.Add(model);
            };

            if (InvokeRequired)
            {
                Invoke(methodInvokerDelegate);
            }
            else
            {
                methodInvokerDelegate();
            }
        }
        private async Task RemoveBookmarkFromFavorite(HistoryItemViewModel hvm)
        {
            ViewModel.IsLoading = true;

            ViewModel.FavoriteSection.Remove(hvm);

            try
            {
                var idx = AppGlobal.BookmarkList.FindIndex(bk => bk.SeriesTitle == hvm.SeriesTitle);
                if (idx >= 0)
                {
                    AppGlobal.BookmarkList.RemoveAt(idx);
                    await AppGlobal.SaveBookmarkDataAsync();
                }

                if (AppGlobal.IsSignedIn)
                {
                    var favDeSer = (from fav in AppGlobal.User.FavoriteList where fav.SeriesTitle == hvm.SeriesTitle select fav.FavId).ToArray();
                    if (favDeSer.Any(id => id == null))
                    {
                        await AppGlobal.User.SyncFavoriteListAsync(true);

                        (from fav in AppGlobal.User.FavoriteList where fav.SeriesTitle == hvm.SeriesTitle select fav.FavId).ToArray();
                    }

                    await AppGlobal.User.RemoveUserFavriteAsync(favDeSer);
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("Exception happens when deleting favorite");
            }

            //ViewModel.FavoriteSection.NotifyPropertyChanged("IsEmpty");
            ViewModel.IsLoading = false;
        }
示例#13
0
 public void AddHistoryItem(HistoryItemViewModel vm, int studentId)
 {
     DatabaseProvider.AddHistoryItem(vm.AlgorithmName, vm.Date, vm.Value, studentId);
 }
 public RemoveHistoryItemMessage(HistoryItemViewModel item)
 {
     Item = item;
 }
示例#15
0
        public async Task <IActionResult> History(int id, int page = 1)
        {
            try
            {
                int take    = 15;
                int skip    = take * (page - 1);
                var history = await _userService
                              .GetPaginatedUserHistoryAsync(id, skip, take);

                PaginateViewModel paginateModel = new PaginateViewModel()
                {
                    ItemCount    = history.Count,
                    CurrentPage  = page,
                    ItemsPerPage = take
                };
                if (paginateModel.MaxPage > 0 && paginateModel.CurrentPage > paginateModel.MaxPage)
                {
                    return(RedirectToRoute(
                               new
                    {
                        page = paginateModel.LastPage ?? 1
                    }));
                }

                var user = await _userService.GetDetails(id);

                SetPageTitle(user);

                HistoryListViewModel viewModel = new HistoryListViewModel()
                {
                    Historys       = new List <HistoryItemViewModel>(),
                    PaginateModel  = paginateModel,
                    Id             = id,
                    HouseholdCount = await _userService
                                     .FamilyMemberCountAsync(user.HouseholdHeadUserId ?? id),
                    HeadOfHouseholdId = user.HouseholdHeadUserId,
                    HasAccount        = !string.IsNullOrWhiteSpace(user.Username),
                    CanRemoveHistory  = UserHasPermission(Permission.LogActivityForAny),
                    TotalPoints       = user.PointsEarned
                };

                bool editChallenges = UserHasPermission(Permission.EditChallenges);

                foreach (var item in history.Data)
                {
                    if (item.ChallengeId != null)
                    {
                        string url = "";
                        if (editChallenges)
                        {
                            url = Url.Action("Edit", "Challenges", new { id = item.ChallengeId });
                        }
                        else
                        {
                            url = Url.Action("Detail", "Challenges",
                                             new { area = "", id = item.ChallengeId });
                        }
                        item.Description = $"<a target='_blank' href='{url}'>{item.Description}</a>";
                    }
                    HistoryItemViewModel itemModel = new HistoryItemViewModel()
                    {
                        Id           = item.Id,
                        CreatedAt    = item.CreatedAt.ToString("d"),
                        Description  = item.Description,
                        PointsEarned = item.PointsEarned,
                    };
                    if (!string.IsNullOrWhiteSpace(item.BadgeFilename))
                    {
                        itemModel.BadgeFilename = _pathResolver.ResolveContentPath(item.BadgeFilename);
                    }
                    viewModel.Historys.Add(itemModel);
                }

                return(View(viewModel));
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to view participant's history: ", gex);
                return(RedirectToAction("Index"));
            }
        }
        private void RecentItem_Click(object sender, ItemClickEventArgs e)
        {
            HistoryItemViewModel item = (HistoryItemViewModel)e.ClickedItem;

            this.Frame.Navigate(typeof(ReadingPage), item.Position.ToString());
        }