public async Task <IActionResult> Edit(int id)
        {
            var announcement = await _naniWebContext.Announcements.SingleAsync(ann => ann.Id == id);

            var model = new EditAnnouncement
            {
                AnnouncementId = announcement.Id,
                Title          = announcement.Title,
                Content        = announcement.Content
            };

            return(View("EditAnnouncement", model));
        }
        public async Task <IActionResult> Edit(EditAnnouncement editAnnouncement)
        {
            if (ModelState.IsValid)
            {
                var announcement = await _naniWebContext.Announcements.SingleAsync(ann => ann.Id == editAnnouncement.AnnouncementId);

                announcement.Title   = editAnnouncement.Title;
                announcement.Content = editAnnouncement.Content;
                announcement.UrlSlug = Utils.GenerateSlug(editAnnouncement.Title);

                _naniWebContext.Announcements.Update(announcement);
                await _naniWebContext.SaveChangesAsync();

                return(RedirectToAction("List"));
            }

            TempData["Error"] = true;

            return(RedirectToAction("Edit", new { id = editAnnouncement.AnnouncementId }));
        }