public bool DeleteRate(long id, ClaimsPrincipal currentLoggedUser) { var loggedUserID = currentLoggedUser.GetUserID(); var isCurrentLoggedUserAdmin = new[] { Roles.ContentManager.ToString(), Roles.Administrator.ToString() }.Contains(currentLoggedUser.GetUserRole()); var rate = MoviesRepository.GetRateById(id); if (rate == null) { return(false); } if (rate.UserID != loggedUserID && !isCurrentLoggedUserAdmin) { throw new UnauthorizedAccessException(); } MoviesRepository.DeleteRate(id); return(true); }