public IActionResult CustomFeedback(FeedbackItemModel entity, int courseId, int count) { var currentUserId = userBLL.GetByEmail(CurrentUser.email).id; var studentsinCourse = courseBLL.AllStudentOfACourse(courseId); List <int> choosen = new List <int>(); for (int i = 0; i < count; i++) { var canPick = studentsinCourse.Except(choosen).Except((new int[] { currentUserId }).ToList()).ToList(); int index = Database.random.Next(canPick.Count()); choosen.Add(canPick[index]); } foreach (var item in choosen) { feedbackBLL.Add(new FeedbackModel() { courseId = courseId, fromUserId = item, toUserId = currentUserId }, false); } return(Redirect("/course/list")); }