Пример #1
0
        public IActionResult AddAnnouncement([FromForm] ContestAnnouncementViewModel model)
        {
            if (ModelState.IsValid)
            {
                var announcement = new Announcement
                {
                    AnnouncementContent = model.AnnouncementContent,
                    ContestId           = model.Contestid,
                    DateAdded           = DateTime.Now,
                    AnnouncementId      = Guid.NewGuid()
                };

                _announcementRepository.Create(announcement);
                _announcementRepository.Save();

                return(RedirectToAction(nameof(Announcement), new { id = model.Contestid }));
            }
            return(BadRequest("Something bad happened"));
        }