///<inheritdoc/>
        public override async Task <bool> InitializeAsync()
        {
            bool result = await base.InitializeAsync();

            if (!result)
            {
                return(false);
            }

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { nameof(Card.DeckId), Entity.DeckId }
            };
            ApiReply <List <PracticeHistoryEntry> > reply = await ApiConnector.GetAsync <PracticeHistoryEntry>(parameters);

            if (!reply.WasSuccessful)
            {
                NotificationMessageProvider.ShowErrorMessage(reply.ResultMessage);
                return(false);
            }

            PracticeHistoryEntries.AddRange(reply.Result);
            SelectableDisplayUnits.Add(EntityNameHelper.GetName <Deck>());
            SelectableDisplayUnits.AddRange(Entity.Cards.Select(card => card.GetDisplayName()));
            foreach (Card card in Entity.Cards)
            {
                cardIdLookup.Add(card.GetDisplayName(), card.CardId);
            }
            SelectedDisplayUnit = SelectableDisplayUnits.First();
            return(true);
        }
        private async Task DeleteCoreAsync(TEntity entity)
        {
            ApiReply reply = await ApiConnector.DeleteAsync(entity);

            if (reply.WasSuccessful)
            {
                NotificationMessageProvider.ShowSuccessMessage(Messages.EntityDeleted.FormatWith(entity.GetDisplayName()));
                OnDeletedAction?.Invoke(entity);
            }
            else
            {
                NotificationMessageProvider.ShowErrorMessage(reply.ResultMessage);
            }
            IsEnabled = true;
        }
        ///<inheritdoc/>
        public override async void ExecuteCommand(object param = null)
        {
            ApiReply <TEntity> reply;

            if (IsNewEntity)
            {
                reply = await ApiConnector.PostAsync(Entity);
            }
            else
            {
                reply = await ApiConnector.PutAsync(Entity);
            }

            if (reply.WasSuccessful)
            {
                NotificationMessageProvider.ShowSuccessMessage(Messages.EntitySaved.FormatWith(Entity.GetDisplayName()));
                OnSavedAction.Invoke(reply.Result);
            }
            else
            {
                NotificationMessageProvider.ShowErrorMessage(reply.ResultMessage);
            }
        }
        /// <summary>
        /// Loads the Entity
        /// </summary>
        protected virtual async Task <bool> LoadEntityAsync()
        {
            ApiReply <TEntity> reply = await ApiConnector.GetAsync <TEntity>(Id);

            if (reply.WasSuccessful)
            {
                Entity = reply.Result;
                return(true);
            }
            else
            {
                if (reply.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    NotificationMessageProvider.ShowErrorMessage(
                        Errors.EntityDoesNotExist.FormatWith(EntityNameHelper.GetName <TEntity>(), Id));
                }
                else
                {
                    NotificationMessageProvider.ShowErrorMessage(reply.ResultMessage);
                }
                return(false);
            }
        }
 public async Task ShowErrorMessageTest()
 {
     NotificationMessageProvider.ShowErrorMessage("test4");
     await TestCore(NotificationKind.ErrorNotification, "test4");
 }