Beispiel #1
0
        public async Task <IActionResult> OnPost(int expertId)
        {
            Expert = expertData.GetById(expertId);
            if (Expert == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            userProfile          = accountData.GetById(Expert.userId);
            userProfile.IsExpert = false;
            accountData.Update(userProfile);

            foreach (var answer in Expert.Answers)
            {
                answerData.Delete(answer);
            }

            await answerData.Commit();

            expertData.Delete(Expert);

            if (await expertData.Commit())
            {
                if (await accountData.Commit())
                {
                    TempData["Message"] = $"Expert {Expert.firstName} {Expert.lastName} Deleted";
                    return(RedirectToPage("./ManageExperts"));
                }
            }
            return(RedirectToPage("./NotFound"));
        }
        public async Task <IActionResult> OnPost(int questionId)
        {
            Question = questionData.GetById(questionId);
            if (Question == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            if (Question.answered == true)
            {
                answerData.Delete(Question.Answer);
                await answerData.Commit();
            }

            questionData.Delete(Question);
            await answerData.Commit();

            TempData["Message"] = $"Question Deleted";
            return(RedirectToPage("./QuestionList", new { questionTypeId = Question.typeId }));
        }