internal static void DeleteMatchById(int matchId) { using (var _context = new bbbsDbContext()) { var match = _context.BigLittleParentMaps.FirstOrDefault(x => x.Id == matchId); _context.BigLittleParentMaps.Remove(match); _context.SaveChanges(); } }
public static UserAccountModel CreateUser(UserAccountModel userModel) { using (var _context = new bbbsDbContext()) { var newUser = _context.Add(TransformHelpers.ModelToUserAccount(userModel)); _context.SaveChanges(); userModel.Id = newUser.Entity.Id; return(userModel); } }
public static UserTypeModel CreateUserContactInfo(UserTypeModel userTypeModel) { using (var _context = new bbbsDbContext()) { var newUserType = _context.Add(new UserType { UserTypeName = userTypeModel.UserTypeName }); _context.SaveChanges(); userTypeModel.Id = newUserType.Entity.Id; return(userTypeModel); } }
public static InterestModel CreateInterest(InterestModel interestModel) { using (var _context = new bbbsDbContext()) { var newInterest = _context.Add(new Interest { InterestName = interestModel.InterestName }); _context.SaveChanges(); interestModel.Id = newInterest.Entity.Id; return(interestModel); } }
public static InterestUserMapModel CreateInterestUserMap(InterestUserMapModel mapModel) { using (var _context = new bbbsDbContext()) { var newMap = _context.Add(new InterestUserMap { InterestId = mapModel.InterestId, UserAccountId = mapModel.UserAccountId }); _context.SaveChanges(); mapModel.Id = newMap.Entity.Id; return(mapModel); } }
public static LittleParentMapModel CreateLittleParentMap(LittleParentMapModel mapModel) { using (var _context = new bbbsDbContext()) { var newMap = _context.Add(new LittleParentMap { LittleId = mapModel.LittleId, ParentId = mapModel.ParentId }); _context.SaveChanges(); mapModel.Id = newMap.Entity.Id; return(mapModel); } }
public static ContactInfoModel CreateUserContactInfo(ContactInfoModel contactInfoModel) { using (var _context = new bbbsDbContext()) { var newContactInfo = _context.Add(new ContactInfo { Email = contactInfoModel.Email, PhoneNumber = contactInfoModel.PhoneNumber, UserAccountId = contactInfoModel.UserAccountId, UserAddressId = contactInfoModel.UserAddressId }); _context.SaveChanges(); contactInfoModel.Id = newContactInfo.Entity.Id; return(contactInfoModel); } }
public static UserAddressModel CreateUserAddress(UserAddressModel addressModel) { using (var _context = new bbbsDbContext()) { var newAddress = _context.Add(new UserAddress { City = addressModel.City, Zip = addressModel.Zip, StreetLine1 = addressModel.StreetLine1, StreetLine2 = addressModel.StreetLine2, State = addressModel.State }); _context.SaveChanges(); addressModel.Id = newAddress.Entity.Id; return(addressModel); } }
public static ContactInfoModel UpdateUserContactInfo(ContactInfoModel contactInfoModel) { using (var _context = new bbbsDbContext()) { var existingContactInfo = _context.ContactInfo.FirstOrDefault(x => x.Id == contactInfoModel.Id); if (existingContactInfo != null) { existingContactInfo.Email = contactInfoModel.Email; existingContactInfo.PhoneNumber = contactInfoModel.PhoneNumber; existingContactInfo.UserAccountId = existingContactInfo.UserAccountId; existingContactInfo.UserAddressId = existingContactInfo.UserAddressId; _context.SaveChanges(); return(contactInfoModel); } } return(null); }
public static UserAddressModel UpdateUserAddress(UserAddressModel userAddressModel) { using (var _context = new bbbsDbContext()) { var existingUserAddress = _context.UserAddresses.FirstOrDefault(x => x.Id == userAddressModel.Id); if (existingUserAddress != null) { existingUserAddress.StreetLine1 = userAddressModel.StreetLine1; existingUserAddress.StreetLine2 = userAddressModel.StreetLine2; existingUserAddress.City = userAddressModel.City; existingUserAddress.State = userAddressModel.State; existingUserAddress.Zip = userAddressModel.Zip; _context.SaveChanges(); return(userAddressModel); } } return(null); }
public static UserAccountModel UpdateUserAccount(UserAccountModel userModel) { using (var _context = new bbbsDbContext()) { var existingUser = _context.UserAccounts.FirstOrDefault(x => x.Id == userModel.Id); if (existingUser != null) { existingUser.FirstName = userModel.FirstName; existingUser.LastName = userModel.LastName; existingUser.UserName = userModel.UserName; existingUser.UserTypeId = userModel.UserTypeId; existingUser.Age = userModel.Age; _context.SaveChanges(); return(TransformHelpers.UserAccountToModel(existingUser)); } } return(null); }
public static BigLittleParentMapModel CreateBigLittleParentMapModel(BigLittleParentMapModel mapModel) { using (var _context = new bbbsDbContext()) { int parentId = FindParentForLittle(mapModel.LittleId).user.Id; var parentLittleMatch = (from lpm in _context.LittleParentMaps where lpm.LittleId == mapModel.LittleId && lpm.ParentId == parentId select lpm).FirstOrDefault(); var newMap = _context.Add(new BigLittleParentMap { BigId = mapModel.BigId, LittleParentMapId = parentLittleMatch.Id, }); _context.SaveChanges(); mapModel.MatchId = newMap.Entity.Id; return(mapModel); } }