예제 #1
0
        public async Task <IActionResult> Add(Review review)
        {
            var LoggedInUser = _userManager.GetUserAsync(HttpContext.User).Result;

            review.UserName = LoggedInUser.UserName;
            _reviewManager.AddNewReview(review);

            foreach (var u in LoggedInUser.Subscribers)
            {
                Notification n = new Notification()
                {
                    UserId  = u,
                    Object  = review._id,
                    Time    = DateTime.Now,
                    Message = LoggedInUser + " has just uploaded a new Review. ",
                    WasRead = false
                };
                _notificationManager.AddNewNotification(n);
                var TargetUser = _userManager.FindByIdAsync(u.ToString()).Result;
                TargetUser.UnreadNotifications++;
                IdentityResult result = await _userManager.UpdateAsync(TargetUser);
            }
            return(LocalRedirect("/"));
        }