Example #1
0
        public ConsolidatedUserInformationResponseModel GetConsolidatedUserInfo(int UserId)

        {
            var newModel = new ConsolidatedUserInformationResponseModel();

            newModel.user    = TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(UserId));
            newModel.address = AddressService.GetAddressForUser(UserId);
            newModel.contactInfo.UserAddressId = newModel.address.Id;
            newModel.contactInfo = ContactInfoService.GetUserContactInfo(UserId);
            newModel.interests   = InterestService.GetUserInterests(UserId);

            return(newModel);
        }
Example #2
0
        internal static MatchedBigLittleParentModel GetMatch(int matchId)
        {
            using (var _context = new bbbsDbContext())
            {
                MatchedBigLittleParentModel matchedBLPM = new MatchedBigLittleParentModel();
                var matchedUsers = (from ua in _context.UserAccounts
                                    from lpm in _context.LittleParentMaps
                                    from blpm in _context.BigLittleParentMaps
                                    where lpm.Id == blpm.LittleParentMapId &&
                                    ((blpm.Id == matchId) && (ua.Id == lpm.LittleId || ua.Id == lpm.ParentId || ua.Id == blpm.BigId))
                                    select ua).Distinct().ToList();

                if (matchedUsers != null)
                {
                    matchedBLPM.MatchId = matchId;
                    foreach (var match in matchedUsers)
                    {
                        var newModel = new ConsolidatedUserInformationResponseModel();

                        newModel.user    = TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(match.Id));
                        newModel.address = AddressService.GetAddressForUser(match.Id);
                        newModel.contactInfo.UserAddressId = newModel.address.Id;
                        newModel.contactInfo = ContactInfoService.GetUserContactInfo(match.Id);
                        newModel.interests   = InterestService.GetUserInterests(match.Id);

                        switch (match.UserTypeId)
                        {
                        case 1:
                            matchedBLPM.Big = newModel;
                            break;

                        case 2:
                            matchedBLPM.Little = newModel;
                            break;

                        case 3:
                            matchedBLPM.Parent = newModel;
                            break;
                        }
                    }
                    matchedBLPM.sharedInterests = InterestService.GetSharedInterest(matchedBLPM.Big.user.Id, matchedBLPM.Little.user.Id).ToList();
                    return(matchedBLPM);
                }
                else
                {
                    return(null);
                }
            }
        }
Example #3
0
        public static ConsolidatedUserInformationResponseModel FindParentForLittle(int littleId)
        {
            using (var _context = new bbbsDbContext())
            {
                var mapping = (from lpm in _context.LittleParentMaps
                               where lpm.LittleId == littleId
                               select lpm).FirstOrDefault();
                UserAccount parentAccount = null;
                if (mapping != null)
                {
                    parentAccount = _context.UserAccounts.FirstOrDefault(x => x.Id == mapping.ParentId);
                }
                ConsolidatedUserInformationResponseModel uam = null;
                if (parentAccount != null)
                {
                    uam = TransformHelpers.UserAccountToConsResModel(parentAccount);
                }

                return(uam);
            }
        }
Example #4
0
        internal static List <MatchedBigLittleParentModel> GetAllMatches()
        {
            using (var _context = new bbbsDbContext())
            {
                var query = (from blpm in _context.BigLittleParentMaps
                             join lpm in _context.LittleParentMaps on blpm.LittleParentMapId equals lpm.Id
                             from ua in _context.UserAccounts
                             where blpm.BigId == ua.Id || lpm.LittleId == ua.Id || lpm.ParentId == ua.Id
                             select new UserAccountWithMatchId
                {
                    MatchId = blpm.Id,
                    FirstName = ua.FirstName,
                    LastName = ua.LastName,
                    Id = ua.Id,
                    Password = ua.Password,
                    UserName = ua.UserName,
                    UserTypeId = ua.UserTypeId,
                    Age = ua.Age
                })
                            .Distinct().ToList();

                var matchesQuery = query.GroupBy(key => new { key.MatchId }, model => new UserAccountModel
                {
                    Id         = model.Id,
                    FirstName  = model.FirstName,
                    LastName   = model.LastName,
                    UserName   = model.UserName,
                    UserTypeId = model.UserTypeId,
                    Password   = model.Password,
                    Age        = model.Age,
                    PictureUrl = model.PictureUrl
                }).ToDictionary(y => y.Key, z => z.ToList());

                List <MatchedBigLittleParentModel> matches = new List <MatchedBigLittleParentModel>();
                foreach (var key in matchesQuery.Keys)
                {
                    MatchedBigLittleParentModel currentMatch = new MatchedBigLittleParentModel();
                    foreach (var match in matchesQuery[key])
                    {
                        var newModel = new ConsolidatedUserInformationResponseModel();

                        newModel.user    = TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(match.Id));
                        newModel.address = AddressService.GetAddressForUser(match.Id);
                        newModel.contactInfo.UserAddressId = newModel.address.Id;
                        newModel.contactInfo = ContactInfoService.GetUserContactInfo(match.Id);
                        newModel.interests   = InterestService.GetUserInterests(match.Id);

                        switch (match.UserTypeId)
                        {
                        case 1:
                            currentMatch.Big = newModel;
                            break;

                        case 2:
                            currentMatch.Little = newModel;
                            break;

                        case 3:
                            currentMatch.Parent = newModel;
                            break;
                        }
                    }
                    currentMatch.sharedInterests = InterestService.GetSharedInterest(currentMatch.Big.user.Id, currentMatch.Little.user.Id).ToList();
                    currentMatch.MatchId         = key.MatchId;
                    matches.Add(currentMatch);
                }
                return(matches);
            }
        }