public async Task <IActionResult> Update([FromHeader] string authToken, string id, AnnouncementUpdate announcementIn) { if (!await _authenticationService.CheckAccess(authToken, "announceMgr")) { return(Unauthorized()); } var announcement = await _announcementService.Get(id); if (announcement == null) { return(NotFound()); } _announcementService.Update(announcement, announcementIn); await _logService.Create(new Log( null, AuthenticationHelpers.GetUserIdFromToken(authToken), DateTime.UtcNow, "Document modified.", "announcements", id, JsonSerializer.Serialize(Announcement.FromUpdate(announcement, announcementIn)) )); return(Ok()); }
public async void Update(Announcement original, AnnouncementUpdate update) => await _announcements.ReplaceOneAsync(announcement => announcement.Id == original.Id, Announcement.FromUpdate(original, update));