public ConsolidatedUserInformationResponseModel CreateConsolidatedUser([FromBody] JObject jmodel) { var Model = new ConsolidatedUserInformationInputModel() { UserAccount = jmodel["user"].ToObject <UserAccountModel>(), UserAddress = jmodel["address"].ToObject <UserAddressModel>(), ContactInfo = jmodel["contactInfo"].ToObject <ContactInfoModel>(), Interests = jmodel["interests"].ToObject <List <InterestModel> >() }; Model.UserAccount = UserAccountService.CreateUserAccount(Model.UserAccount); Model.UserAddress = AddressService.CreateUserAddress(Model.UserAddress); Model.ContactInfo.UserAccountId = Model.UserAccount.Id; Model.ContactInfo.UserAddressId = Model.UserAddress.Id; Model.ContactInfo = ContactInfoService.CreateUserContactInfo(Model.ContactInfo); if (Model.Interests != null) { foreach (var Interest in Model.Interests) { var NewMapping = new InterestUserMapModel { UserAccountId = Model.UserAccount.Id, InterestId = Interest.Id }; InterestService.CreateInterestUserMap(NewMapping); } } Model.Interests = InterestService.GetUserInterests(Model.UserAccount.Id); return(TransformHelpers.UserInputModelToUserResponseModel(Model)); }
public static ConsolidatedUserInformationResponseModel UserAccountToConsResModel(UserAccount parentAccount) { return(new ConsolidatedUserInformationResponseModel() { address = AddressService.GetAddressForUser(parentAccount.Id), contactInfo = ContactInfoService.GetUserContactInfo(parentAccount.Id), interests = InterestService.GetUserInterests(parentAccount.Id), user = DtoToUserAccountViewModel(parentAccount) }); }
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); }
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); } } }
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); } }
public IEnumerable <InterestModel> GetUserInterests(int userId) { return(InterestService.GetUserInterests(userId)); }