Exemplo n.º 1
0
        public GuildAnnouncement AddAnnouncement(GuildAnnouncement announcementToAdd)
        {
            DateTime dateTime = DateTime.Now;

            var sql = @"
                        insert into[GuildAnnouncements](GuildId, AnnouncementDateTime, AnnouncementText)
                        output inserted.*
                        values(@GuildId, @AnnouncementDateTime, @AnnouncementText);
                        ";

            using (var db = new SqlConnection(connectionString))
            {
                var parameters = new
                {
                    GuildId = announcementToAdd.GuildId,
                    AnnouncementDateTime = dateTime,
                    AnnouncementText     = announcementToAdd.AnnouncementText
                };
                var result = db.QueryFirstOrDefault <GuildAnnouncement>(sql, parameters);
                return(result);
            }
        }
Exemplo n.º 2
0
        public IActionResult CreateNewAnnouncement(GuildAnnouncement newAnnouncementToAdd)
        {
            var announcement = _announcementsRepo.AddAnnouncement(newAnnouncementToAdd);

            return(Created("Create new announcement successfully", announcement));
        }