Пример #1
0
        public async Task <IActionResult> DeleteNoticeAsync(string id)
        {
            try
            {
                string userId = User.Claims.FirstOrDefault(c => c.Type == JwtRegisteredClaimNames.Sub).Value;

                await _noticesRepository.DeleteNoticeAsync(userId, id);

                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Пример #2
0
        public async Task TestDeleteNotice()
        {
            try
            {
                User user = await _usersCollection.Find(u => u.Id == "60848ae8fb71edf2a7ebf846").FirstOrDefaultAsync();

                Assert.AreEqual(1, user.Notices.Count());

                await _noticesRepository.DeleteNoticeAsync(user.Id, "608235aea059ac5c9af6da20");

                user = await _usersCollection.Find(u => u.Id == "60848ae8fb71edf2a7ebf846").FirstOrDefaultAsync();

                Assert.Zero(user.Notices.Count());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                await _usersRepository.DeleteUserAsync("60848ae8fb71edf2a7ebf846");
            }
        }