Esempio n. 1
0
        /// <summary>Loads the media objects from database asynchronous.</summary>
        internal async Task LoadMediaObjectsFromDBAsync()
        {
            foreach (var challenge in ChallengesFromDB)
            {
                switch (challenge.GetDiscriminator())
                {
                case "AudienceChallenge":
                case "CrewChallenge":
                case "SologameChallenge":
                    if ((challenge as GameChallenge).GameID != 0 && (challenge as GameChallenge).Game == null)
                    {
                        try{
                            (challenge as GameChallenge).Game = await MediaObjectsDataAccess.GetMediaObjectAsync((challenge as GameChallenge).GameID, "Game") as Game;
                        }
                        catch (Exception) { }
                    }
                    break;

                case "MultipleChoiceChallenge":
                case "QuizChallenge":
                    if ((challenge as QuestionChallenge).AnswersID != 0 && (challenge as QuestionChallenge).Answers == null)
                    {
                        try {
                            (challenge as QuestionChallenge).Answers = await AnswersDataAccess.GetAnswersAsync((challenge as QuestionChallenge).AnswersID);
                        } catch (Exception) { }
                    }
                    break;

                case "MusicChallenge":
                    if ((challenge as MusicChallenge).SongID != 0 && (challenge as MusicChallenge).Song == null)
                    {
                        try {
                            (challenge as MusicChallenge).Song = await MediaObjectsDataAccess.GetMediaObjectAsync((challenge as MusicChallenge).SongID, "Music") as Music;
                        } catch (Exception) { }
                    }
                    break;

                case "ScreenshotChallenge":
                case "SilhouetteChallenge":
                    if ((challenge as ImageChallenge).ImageID != 0 && (challenge as ImageChallenge).Image == null)
                    {
                        try
                        {
                            (challenge as ImageChallenge).Image = await MediaObjectsDataAccess.GetMediaObjectAsync((challenge as ImageChallenge).ImageID, "Image") as Modell.ChallengeObjects.Image;
                        } catch (Exception) { }
                    }
                    break;
                }
            }
        }
Esempio n. 2
0
        /// <summary>Initializes a new instance of the <see cref="CreateChallengesViewModel"/> class.</summary>
        public CreateChallengesViewModel()
        {
            EditCommand = new RelayCommand <ChallengeBase>(async param =>
            {
                switch (param.GetDiscriminator())
                {
                case "AudienceChallenge":
                case "CrewChallenge":
                case "SologameChallenge":
                    ObjectsViewModel.EditCommand.Execute((param as GameChallenge).Game);
                    break;

                case "MultipleChoiceChallenge":
                case "QuizChallenge":
                    await AnswersDataAccess.EditAnswersAsync((param as QuestionChallenge).Answers);
                    break;

                case "MusicChallenge":
                    ObjectsViewModel.EditCommand.Execute((param as MusicChallenge).Song);
                    break;

                case "ScreenshotChallenge":
                case "SilhouetteChallenge":
                    ObjectsViewModel.EditCommand.Execute((param as ImageChallenge).Image);
                    break;
                }
                await ChallengesDataAccess.EditChallengeAsync(param);
            }, param => param != null);

            DeleteCommand = new RelayCommand <ChallengeBase>(async param =>
            {
                if (await ChallengesDataAccess.DeleteChallengeAsync(param))
                {
                    switch (param.GetDiscriminator())
                    {
                    case "AudienceChallenge":
                        AudienceChallenges.Remove(param as AudienceChallenge);
                        FilteredAudience.Remove(param as AudienceChallenge);
                        break;

                    case "CrewChallenge":
                        CrewChallenges.Remove(param as CrewChallenge);
                        FilteredCrew.Remove(param as CrewChallenge);
                        break;

                    case "MultipleChoiceChallenge":
                        MultipleChoiceChallenges.Remove(param as MultipleChoiceChallenge);
                        FilteredMulti.Remove(param as MultipleChoiceChallenge);
                        break;

                    case "MusicChallenge":
                        MusicChallenges.Remove(param as MusicChallenge);
                        FilteredMusic.Remove(param as MusicChallenge);
                        break;

                    case "QuizChallenge":
                        QuizChallenges.Remove(param as QuizChallenge);
                        FilteredQuiz.Remove(param as QuizChallenge);
                        break;

                    case "ScreenshotChallenge":
                        ScreenshotChallenges.Remove(param as ScreenshotChallenge);
                        FilteredScreen.Remove(param as ScreenshotChallenge);
                        break;

                    case "SilhouetteChallenge":
                        SilhouetteChallenges.Remove(param as SilhouetteChallenge);
                        FilteredSilhu.Remove(param as SilhouetteChallenge);
                        break;

                    case "SologameChallenge":
                        SologameChallenges.Remove(param as SologameChallenge);
                        FilteredSolo.Remove(param as SologameChallenge);
                        break;
                    }
                }
            }, param => param != null);
        }