public async Task TestGetNotices() { try { IEnumerable <Notice> notices = await _noticesRepository.GetNoticesAsync("60848ae8fb71edf2a7ebf846"); Assert.NotNull(notices); Assert.AreEqual(1, notices.Count()); } catch (Exception ex) { throw ex; } finally { await _usersRepository.DeleteUserAsync("60848ae8fb71edf2a7ebf846"); } }
public async Task <IActionResult> GetNoticesAsync() { try { string userId = User.Claims.FirstOrDefault(c => c.Type == JwtRegisteredClaimNames.Sub).Value; IEnumerable <Notice> notices = await _noticesRepository.GetNoticesAsync(userId); return(Ok(notices)); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }