Beispiel #1
0
        public OperationResultVo Connect(Guid currentUserId, Guid userId, UserConnectionType connectionType)
        {
            try
            {
                UserConnection model = new UserConnection
                {
                    UserId         = currentUserId,
                    TargetUserId   = userId,
                    ConnectionType = connectionType
                };

                UserConnection existing = profileDomainService.GetConnection(currentUserId, userId);

                if (existing != null)
                {
                    return(new OperationResultVo("You are already connected to this user!"));
                }
                else
                {
                    profileDomainService.AddConnection(model);
                }

                unitOfWork.Commit();

                int newCount = profileDomainService.CountConnections(x => (x.TargetUserId == userId || x.UserId == userId) && x.ApprovalDate.HasValue);

                return(new OperationResultVo <int>(newCount));
            }
            catch (Exception ex)
            {
                return(new OperationResultVo(ex.Message));
            }
        }
Beispiel #2
0
        public IActionResult ConnectToUser(Guid userId, UserConnectionType connectionType)
        {
            OperationResultVo response = profileAppService.Connect(CurrentUserId, userId, connectionType);

            string fullName = GetSessionValue(SessionValues.FullName);

            notificationAppService.Notify(CurrentUserId, fullName, userId, NotificationType.ConnectionRequest, CurrentUserId);

            return(Json(response));
        }
Beispiel #3
0
        public IActionResult ConnectToUser(Guid userId, UserConnectionType connectionType)
        {
            OperationResultVo response = profileAppService.Connect(CurrentUserId, userId, connectionType);

            string fullName = GetSessionValue(SessionValues.FullName);

            string text = String.Format(SharedLocalizer["{0} wants to connect."], fullName);

            string url = Url.Action("Details", "Profile", new { id = CurrentUserId });

            notificationAppService.Notify(CurrentUserId, userId, NotificationType.ConnectionRequest, userId, text, url);

            return(Json(response));
        }
 public IEnumerable <UserConnection> GetConnectionByUserId(Guid userId, UserConnectionType type, bool bothWays)
 {
     return(GetConnectionByUserId(userId, type, false, bothWays));
 }
 public IEnumerable <UserConnection> GetConnectionByTargetUserId(Guid targetUserId, UserConnectionType type)
 {
     return(GetConnectionByTargetUserId(targetUserId, type, false));
 }