Exemple #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"));
        }
Exemple #2
0
        public async Task <IActionResult> OnPost(string userId)
        {
            userProfile          = accountData.GetById(userId);
            userProfile.IsExpert = false;

            expert = expertData.GetByUserId(userId);
            expertData.Delete(expert);

            if (await expertData.Commit() && await accountData.Commit())
            {
                TempData["Message"] = $"Expert {expert.firstName} {expert.lastName} deleted";
                return(RedirectToPage("./ListUsers"));
            }
            return(RedirectToPage("./NotFound"));
        }