Example #1
0
 private Deck ToDeck(Data.Models.Deck deck)
 {
     return(new Deck
     {
         Id = deck.Id,
         Name = deck.Name,
         CreatedOn = deck.CreatedOn.ToShortDateString(),
         CardsCount = deck.CardsCount + " card/s"
     });
 }
        private async void Save()
        {
            if (this.IsBusy)
            {
                return;
            }

            this.ValidName = !string.IsNullOrWhiteSpace(this.Name);

            this.ValidDescription = !string.IsNullOrWhiteSpace(this.Description);

            if (!this.ValidName || !this.ValidDescription)
            {
                return;
            }

            this.IsBusy = true;

            var deck = new Data.Models.Deck
            {
                Name        = this.Name,
                Description = this.Description,
                CardsCount  = 0,
                CreatedOn   = DateTime.UtcNow
            };

            try
            {
                var deckId = await this.DataService.AddNewDeckAsync(deck);
            }
            catch (Exception)
            {
            }

            this.IsBusy = false;
        }