public async Task <IActionResult> FollowProject(string id) { var user = GetAuthenticatedUser(); var project = await _projectRepository.GetAsync(id); var userAgent = HttpContext.Request.Headers["User-Agent"].ToString(); project.Status = StatusHelper.GetProjectStatusFromString(project.ProjectStatus); var sentMails = await _mailSentRepository.GetFollowAsync(); var match = sentMails.FirstOrDefault(x => x.ProjectId == id && x.UserId == user.Email); if (project.Status == Status.Initiative && match == null) { var initiativeMessage = NotificationMessageHelper.GenerateInitiativeMessage(project, user.GetFullName(), user.Email); await _emailsQueue.PutMessageAsync(initiativeMessage); await _mailSentRepository.SaveFollowAsync(user.Email, id); } var follow = await _projectFollowRepository.GetAsync(user.Email, id); if (follow == null) { await _projectFollowRepository.SaveAsync( new ProjectFollowEntity { UserId = user.Email, FullName = user.GetFullName(), ProjectId = id, UserAgent = userAgent }); } return(RedirectToAction("ProjectDetails", "Project", new { id })); }