public async Task <IActionResult> Detail(int petitionID)
        {
            if (TempData["PetitionStatu"] != null)
            {
                ViewBag.PetitionStatu = TempData["PetitionStatu"].ToString();
            }

            if (TempData["ContentStatus"] != null)
            {
                ViewBag.ContentStatus = TempData["ContentStatus"].ToString();
            }


            var user = await _userManager.GetUserAsync(User);

            ListPetitionDetailDto PetitionDetail = _petitionService.ListPetitionDetail(petitionID);

            PetitionDetail.Contents.Reverse();

            if (PetitionDetail.Petition == null)
            {
                TempData["Statu"] = "PetitionNotFound";
                return(RedirectToAction("AllPetitions"));
            }

            PetitionDetail.UserID  = user.Id;
            PetitionDetail.isAdmin = User.IsInRole("Admin");

            return(View(PetitionDetail));
        }
Beispiel #2
0
        public async Task <IActionResult> Detail(int petitionID)
        {
            ViewBag.petitionID = petitionID;


            string contentStatus = string.Empty;

            if (TempData["ContentStatus"] != null)
            {
                contentStatus = TempData["ContentStatus"].ToString();
            }

            ViewBag.ContentSTatus = contentStatus;


            var user = await _userManager.GetUserAsync(User);



            ListPetitionDetailDto PetitionDetailDto = _petitionService.ListPetitionDetail(petitionID);

            PetitionDetailDto.Contents.Reverse();



            //NULL KONTROLÜ
            if (PetitionDetailDto.Petition == null)
            {
                return(RedirectToAction("PetitionNotFound"));
            }


            //NULL DEĞİL, LOGİN DURUMDAKİ KULLANICIYA AİT BİR DİLEKÇE Mİ?
            if (PetitionDetailDto.Petition.UserID != user.Id)
            {
                return(RedirectToAction("PetitionDetailDenied"));
            }


            PetitionDetailDto.UserID  = user.Id;
            PetitionDetailDto.isAdmin = User.IsInRole("Admin");

            return(View(PetitionDetailDto));
        }