Esempio n. 1
0
        internal static List <ShallowMatchedBigLittleParentModel> GetallMatchesShallow()
        {
            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 queryDictionary = 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 <ShallowMatchedBigLittleParentModel> matches = new List <ShallowMatchedBigLittleParentModel>();
                foreach (var key in queryDictionary.Keys)
                {
                    ShallowMatchedBigLittleParentModel currentMatch = new ShallowMatchedBigLittleParentModel();
                    foreach (var match in queryDictionary[key])
                    {
                        switch (match.UserTypeId)
                        {
                        case 1:
                            currentMatch.Big = TransformHelpers.ModelToUserAccountViewModel(match);
                            break;

                        case 2:
                            currentMatch.Little = TransformHelpers.ModelToUserAccountViewModel(match);;
                            break;

                        case 3:
                            currentMatch.Parent = TransformHelpers.ModelToUserAccountViewModel(match);;
                            break;
                        }
                    }
                    currentMatch.MatchId = key.MatchId;
                    matches.Add(currentMatch);
                }
                return(matches);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
                }
            }
        }
Esempio n. 4
0
 public UserAccountViewModel CreateUser(UserAccountModel inputModel)
 {
     return(TransformHelpers.ModelToUserAccountViewModel(UserAccountService.CreateUserAccount(inputModel)));
 }
Esempio n. 5
0
 public UserAccountViewModel GetUserAccount(int userId)
 {
     return(TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(userId)));
 }
Esempio n. 6
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);
            }
        }