public async Task <IActionResult> ViewDeck( Guid deckId, [FromServices] UserManager <DejarixUser> userManager, CancellationToken cancellationToken) { var deck = await _context.Decks .Include(d => d.Revision) .ThenInclude(dr => dr.Cards) .ThenInclude(cidr => cidr.Card) .SingleOrDefaultAsync(d => d.DeckId == deckId, cancellationToken); if (deck is null) { return(NotFound()); } else { var model = new DeckViewModel { Deck = deck, PageTitle = deck.Revision?.Title ?? deck.DeckId.ToString() }; if (User.Identity.IsAuthenticated) { var user = await userManager.GetUserAsync(User); model.ShowEditLink = user.Id == deck.CreatorId; } return(View(model)); } }
public IActionResult View() { var list = _context.DeckCards.Include(x => x.Card).Include(x => x.Deck).Where(x => x.DeckID == 1).ToList(); var results = list.GroupBy(g => g.CardID).ToList(); List <CardAmt> cardAmt = new List <CardAmt>(); foreach (var group in results) { CardAmt ca1 = new CardAmt(); CardDto card = new CardDto(); var groupKey = group.Key; ca1.Amount = group.Count(); card = group.FirstOrDefault().Card; ca1.Card = card; cardAmt.Add(ca1); } DeckViewModel deckViewModel = new DeckViewModel() { Cards = cardAmt }; return(View(deckViewModel)); }
public Deck(string id, string name, int countOfFlashCards) { this.ID = id; this.Name = name; this.CountOfFlashcards = countOfFlashCards; this.ViewModel = new DeckViewModel(); }
// GET: Deck public async Task <IActionResult> Index(string deckClassType, string searchTitleDeck, string searchAuthorDeck) { IQueryable <ClassType> classTypeQuery = from d in _context.Deck orderby d.ClassType select d.ClassType; var decks = from d in _context.Deck select d; if (!String.IsNullOrEmpty(searchTitleDeck)) { decks = decks.Where(s => s.Title.Contains(searchTitleDeck)); } if (!String.IsNullOrEmpty(searchAuthorDeck)) { decks = decks.Where(s => s.Author.Contains(searchAuthorDeck)); } if (!String.IsNullOrEmpty(deckClassType)) { ClassType classConvert = (ClassType)Enum.Parse(typeof(ClassType), deckClassType); decks = decks.Where(x => x.ClassType == classConvert); } var deckClassTypeVM = new DeckViewModel(); deckClassTypeVM.ClassType = new SelectList(await classTypeQuery.Distinct().ToListAsync()); deckClassTypeVM.Decks = await decks.ToListAsync(); deckClassTypeVM.SearchTitleDeck = searchTitleDeck; deckClassTypeVM.SearchAuthorDeck = searchAuthorDeck; return(View(deckClassTypeVM)); }
public Deck(string id, string name, bool isPublic) { this.ID = id; this.Name = name; this.CountOfFlashcards = 0; this.IsPublic = isPublic; this.ViewModel = new DeckViewModel(); }
public IActionResult Deck(DeckViewModel model) { var currentUser = HttpContext.User.Identity.Name; var playerCards = this._playerService.GetPlayerCards(currentUser); model.PlayersCards = playerCards; return(View(model)); }
public MainPage() { InitializeComponent(); fvm = new FlashCardViewModel(); dvm = new DeckViewModel(); DefinitionList.DataContext = fvm; DeckList.DataContext = dvm; listPicker.DataContext = dvm; }
public ActionResult Edit(DeckViewModel deckVM) { if (ModelState.IsValid) { repo.Update(ToModel(deckVM)); repo.Save(); return(RedirectToAction("Index")); } return(View(deckVM)); }
private void MenuFlyoutItem_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { MenuFlyoutItem item = sender as MenuFlyoutItem; PlayerClass _class = (PlayerClass)Enum.Parse(typeof(PlayerClass), item.Text, true); DeckViewModel deck = new DeckViewModel(1, "123", _class); masterViewModel.Decks.Add(deck); masterViewModel.SelectedDeck = deck; this.Frame.Navigate(typeof(DeckDetail), null, new DrillInNavigationTransitionInfo()); }
/** * Route used to view detailed information about a deck */ public IActionResult Deck(string id) { //check to see if the deck exists DeckModel deck; try { deck = NoSqlService.GetDeckById(id); } catch { return(RedirectToAction("Index")); } //check to see if the user is logged in if (User.Identity.IsAuthenticated) { var isUsersDeck = string.Compare(deck.Creator, User.Identity.Name, StringComparison.CurrentCulture) == 0; //if the user is logged in, they can view public decks and thier own decks if (!deck.IsPublic && !isUsersDeck) { return(RedirectToAction("Index")); } //if this is the user's deck, they give them editing/deletion controls var viewModel = new DeckViewModel() { Deck = deck, DeckId = deck.Id.ToString(), IsCreator = isUsersDeck }; return(View(viewModel)); } else { //if the user is not logged in, they can only view public decks if (!deck.IsPublic) { return(RedirectToAction("Index")); } var viewModel = new DeckViewModel() { Deck = deck, IsCreator = false }; return(View(viewModel)); } }
public DeckPage(Deck deck, bool active = true) { InitializeComponent(); this.Dialogs = UserDialogs.Instance; this.Active = active; if (active) { Deck = ConfigurationManager.ActiveDeck = deck; } else { Deck = deck; this.ManageToolbarItem.Text = "Save As"; } this.BindingContext = viewModel = new DeckViewModel(Deck); }
private Deck ToModel(DeckViewModel deckVM) { Deck deck; if (deckVM.id == null) { deck = new Deck() { name = deckVM.name }; } else { deck = repo.Get(deckVM.id); deck.name = deckVM.name; } ReplaceTasks(deck, deckVM.tasks); return(deck); }
public async Task <IActionResult> CreateDeck(DeckViewModel deckViewModel) { if (!ModelState.IsValid) { return(View(deckViewModel)); } var result = await _flashcardClient.CreateDeck(deckViewModel.Name); if (!result.isSuccess) { foreach (var err in result.Errors.ErrorItems.Name) { ModelState.AddModelError(err, err); } ModelState.AddModelError("errorCreation", "Problem creating a deck"); return(View(deckViewModel)); } return(RedirectToAction("Index")); }
public DeckViewModel Get() { // get deck from repository var deckModel = _deckRepository.Get(); _deckViewModel = new DeckViewModel(); List <CardViewModel> lstCardViewModels = new List <CardViewModel>(); foreach (ICard card in deckModel.Cards) { CardViewModel vmCard = GetViewModelFromModel(card); lstCardViewModels.Add(vmCard); } DeckViewModel viewModelDeck = new DeckViewModel(); viewModelDeck.CardList = lstCardViewModels; // return Deck View Model return(viewModelDeck); }
public async Task <ViewResult> Index(int id) { var deck = await _flashcardClient.GetDeckById(id); var cardsByDeckId = await _flashcardClient.GetCardsByDeckId(id); if (deck != null && cardsByDeckId != null) { var deckViewModel = new DeckViewModel() { Id = deck.Id, Name = deck.Name, TotalCards = deck.totalCards, Cards = cardsByDeckId.Cards }; return(View(deckViewModel)); } else { return(View("NotFound")); } }
public static async Task <List <DeckViewModel> > GetDecksAsync() { IEnumerable <Deck> decks = await GetAsync <IEnumerable <Deck> >(); var deckList = new List <DeckViewModel>(); var CardsPool = new List <AbstractCard>(); await CardData.GetCards(CardsPool, new CardQueryOption()); if (decks == null) { return(deckList); } foreach (var deck in decks) { var items = new List <DeckItemViewModel>(); foreach (var item in deck.items) { string id = item.cardId; int count = item.cardCount; var selected = CardsPool.FirstOrDefault(p => p.cardId == id); if (selected != null) { var t = new DeckItemViewModel(selected, count); items.Add(t); } } DeckViewModel dk = new DeckViewModel(deck.id, deck.name, deck.playerClass, items); deckList.Add(dk); } return(deckList); }
public async Task <IActionResult> Index(string deck, string search) { IQueryable <string> deckQuery = from d in _context.Decks orderby d.Name select d.Name; var decks = from d in _context.Decks select d; if (!String.IsNullOrEmpty(search)) { decks = decks.Where(d => d.Name.Contains(search)); } if (!String.IsNullOrEmpty(deck)) { decks = decks.Where(d => d.Name == deck); } var deckNameVM = new DeckViewModel(); deckNameVM.name = new SelectList(await deckQuery.Distinct().ToListAsync()); deckNameVM.decks = await decks.ToListAsync(); return(View(deckNameVM)); }
public Deck() { this.CountOfFlashcards = 0; this.ViewModel = new DeckViewModel(); }
public DeckTracking( DeckViewModel deckViewModel) { DeckViewModel = deckViewModel; }
async void ManageDeck(object sender, EventArgs args) { if (!Active) { this.Deck.SaveDeckAs(); return; } const string NEW_DECK = "New Deck"; const string NAME_DECK = "Name Deck"; const string OPEN_DECK = "Open Deck"; const string SAVE_DECK_AS = "Save Deck As"; // const string SHARE_DECK = "Share Deck"; const string IMPORT_FROM_DEC = "Import from .dec"; const string EXPORT_TO_DEC = "Export to .dec"; // const string SHARE_AS_DEC = "Share as .dec(Unsupported)"; const string MANAGE_BOARDS = "Manage Visible Boards"; const string ADD_BOARD = "Add Board"; const string REMOVE_BOARD_PREFIX = "Remove Board: "; List <string> actions = new List <string>() { NAME_DECK, OPEN_DECK, SAVE_DECK_AS, IMPORT_FROM_DEC, EXPORT_TO_DEC, MANAGE_BOARDS, ADD_BOARD }; foreach (string name in Deck.BoardNames.Where(n => n != Deck.MASTER)) { actions.Add(REMOVE_BOARD_PREFIX + name); } string action = await this.Dialogs.ActionSheetAsync("Manage Deck", "Cancel", NEW_DECK, null, actions.ToArray()); // string action = await DisplayActionSheet("Manage Deck", "Cancel", NEW_DECK, actions.ToArray()); if (action == NEW_DECK) { this.Deck = ConfigurationManager.ActiveDeck = new Deck(); this.BindingContext = this.viewModel = new DeckViewModel(this.Deck); } else if (action == NAME_DECK) { PromptResult name = await this.Dialogs.PromptAsync(new PromptConfig().SetMessage("Deck Name").SetCancellable(true)); if (name.Ok) { this.Deck.Name = name.Text; } } else if (action == OPEN_DECK) { FileData fileData = await ConfigurationManager.FilePicker.OpenFileAs(); if (fileData is null) { await DisplayAlert("Error", "Failed to open Deck File", "Okay"); } else { if (fileData.FilePath != this.Deck.StoragePath) { string toRelease = this.Deck.StoragePath; ConfigurationManager.ActiveDeck = this.Deck = Deck.FromJdec(fileData.FilePath); this.BindingContext = viewModel = new DeckViewModel(this.Deck); ConfigurationManager.FilePicker.ReleaseFile(toRelease); } } } else if (action == SAVE_DECK_AS) { this.Deck.SaveDeckAs(); } else if (action == IMPORT_FROM_DEC) { FileData fileData = await ConfigurationManager.FilePicker.OpenFileAs(); if (fileData is null) { await DisplayAlert("Error", "Failed to import .dec File", "Okay"); } else { if (fileData.FilePath != this.Deck.StoragePath) { string toRelease = this.Deck.StoragePath; ConfigurationManager.ActiveDeck = this.Deck = Deck.FromDec(fileData.FilePath); this.BindingContext = viewModel = new DeckViewModel(this.Deck); ConfigurationManager.FilePicker.ReleaseFile(toRelease); } } } else if (action == EXPORT_TO_DEC) { this.Deck.SaveAsDec(); } else if (action == MANAGE_BOARDS) { await Navigation.PushAsync(new BoardEditing(this.Deck)); } else if (action == ADD_BOARD) { PromptResult result = await this.Dialogs.PromptAsync(new PromptConfig().SetMessage("Board Name")); if (result.Ok) { this.Deck.AddBoard(result.Text); } } else if (action.StartsWith(REMOVE_BOARD_PREFIX)) { string name = action.Substring(REMOVE_BOARD_PREFIX.Length); this.Deck.RemoveBoard(name); } }
public Deck(string id) { this.ID = id; this.CountOfFlashcards = 0; this.ViewModel = new DeckViewModel(); }