public async Task <ActionResult> Connect(int companyId) { if (int.TryParse(User.GetClaimValue(Common.Constants.CompanyIdClaim), out var connectedCompanyId)) { var connection = _connectionRepository.Get(companyId, connectedCompanyId); if (connection != null) { if (connection.Status == ConnectionStatus.Rejected) { connection.Status = ConnectionStatus.Requested; await _connectionRepository.UpdateAsync(connection); _notificationService.Create(NotificationType.Email, EventType.ConnectionRequest, connection.Id); } } else { connection = await _connectionRepository.CreateAsync(companyId, connectedCompanyId); _notificationService.Create(NotificationType.Email, EventType.ConnectionRequest, connection.Id); } } return(RedirectToAction("Details", "Business", new { id = companyId })); }