コード例 #1
0
ファイル: Index.cshtml.cs プロジェクト: Hlosani-M/PhoneBook
        public IActionResult OnPostDelete(int entryId)
        {
            var entry = _entryRepository.GetEntryById(entryId);

            if (entry == null)
            {
                SearchMessage = "Entry not found.";
                return(Page());
            }

            Entry = _entryRepository.DeleteEntry(entryId);
            _entryRepository.Commit();

            SearchMessage = $"{Entry.Name}'s entry deleted successfully";

            return(RedirectToPage());
        }
コード例 #2
0
        public ActionResult Delete(int entryId)
        {
            var entry = _entryRepo.GetEntry(entryId);

            if (entry == null)
            {
                return(HttpNotFound());
            }

            GetSignedUser();
            if (!_signedUser.CanManageAllContent() && !entry.Account.Equals(_signedUser))
            {
                return(RedirectToAction("Index", "Home"));
            }

            _entryRepo.DeleteEntry(entryId);

            return(RedirectToAction("Index", "Entries"));
        }