Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteRange(ReviewParams revParams)
        {
            int reviewerId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var user       = await _repo.GetUser(reviewerId);

            var isAdmin = await _userManager.IsInRoleAsync(user, "Admin");

            if (!isAdmin)
            {
                return(Unauthorized());
            }
            var reviews = await _repo.GetReviewsForDelete(revParams);

            _repo.RemoveMultiple(reviews);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("Could not delete Reviews"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DeleteMessageRange(DeleteDto dto)
        {
            int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var user   = await _repo.GetUser(userId);

            var isAdmin = await _userManager.IsInRoleAsync(user, "Admin");

            if (!isAdmin)
            {
                return(Unauthorized());
            }
            var messages = await _repo.GetMessagesForDelete(dto);

            _repo.RemoveMultiple(messages);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("Could not delete messages"));
        }