Ejemplo n.º 1
0
        public void Connect()
        {
            var  username   = this.Context.GetHttpContext().User.Identity.Name;
            User activeUser = userDomain.RetrieveUserByUsername(username).Result;

            this.Groups.AddToGroupAsync(this.Context.ConnectionId, GetUserGroupIdentifier(activeUser.Id));
        }
Ejemplo n.º 2
0
        public async Task TransferItemOwner(string recipientUsername, int itemId, User activeUser)
        {
            var recipientUser = await UserDomain.RetrieveUserByUsername(recipientUsername);

            if (recipientUser == null)
            {
                throw new CritterException($"Could not give that item, recipient {recipientUsername} does not exist!",
                                           $"Invalid recipient provided - recipient: {recipientUsername}, giver: {activeUser.Id}",
                                           System.Net.HttpStatusCode.BadRequest);
            }

            await TransferItemOwner(recipientUser.Id, itemId, activeUser.Id);

            //SignalRHubContext?.Clients?.GroupExcept(NotificationHub.GetChannelGroupIdentifier(message.ChannelId), activeUser.Username)
            //    ?.ReceiveNotification(new NewMessageAlert(new MessageDetails() { Message = message, SenderUsername = activeUser.Username }));
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <User> > SearchUsers(string searchString)
        {
            List <User> results = new List <User>();

            if (string.IsNullOrEmpty(searchString))
            {
                return(results);
            }

            if (searchString.IsValidEmail())
            {
                var exactMatch = await UserDomain.RetrieveUserByEmail(searchString);

                if (exactMatch != null)
                {
                    results.Add(exactMatch);
                }
            }
            else
            {
                var topResult = await UserDomain.RetrieveUserByUsername(searchString);

                if (topResult != null)
                {
                    results.Add(topResult);
                }

                try
                {
                    var metaphone = new ShortDoubleMetaphone(searchString);

                    results.AddRange(await UserDomain.RetrieveUsersBySoundsLike(metaphone.PrimaryShortKey));
                    if (metaphone.AlternateShortKey != ShortDoubleMetaphone.METAPHONE_INVALID_KEY && metaphone.AlternateShortKey != metaphone.PrimaryShortKey)
                    {
                        results.AddRange((await UserDomain.RetrieveUsersBySoundsLike(metaphone.AlternateShortKey)));
                    }
                }
                catch (Exception) { }
            }
            return(results.Distinct());
        }
Ejemplo n.º 4
0
        public async Task <IEnumerable <Shop> > GetShops(string ownerUsername)
        {
            User user = await UserDomain.RetrieveUserByUsername(ownerUsername);

            return(user == null ? null : await GetShops(user));
        }