public async Task <ProfileEntity> UpsertProfile(ProfileEntity entity) { var profile = await GetProfile(entity.Id); if (profile == null) { _db.Add(entity); } else { profile.Name = entity.Name; profile.Age = entity.Age; profile.ShowAge = entity.ShowAge; profile.Location = entity.Location; profile.Latitude = entity.Latitude; profile.Longitude = entity.Longitude; profile.Bio = entity.Bio; profile.ContactDetails = entity.ContactDetails; profile.FavouritePosition = entity.FavouritePosition; profile.Gender = entity.Gender; profile.SearchForCategory = entity.SearchForCategory; profile.SearchRadius = entity.SearchRadius; profile.SearchMinAge = entity.SearchMinAge; profile.SearchMaxAge = entity.SearchMaxAge; profile.UpdatedAt = DateTime.UtcNow; _db.Update(profile); } await _db.SaveChangesAsync(); var updatedProfile = await GetProfile(entity.Id); return(updatedProfile); }
public async Task <PairingEntity> UpsertPairingData(PairingEntity entity) { var pairing = await _db.FindAsync <PairingEntity>(entity.Id); if (pairing == null) { _db.Add <PairingEntity>(entity); } else { _db.Update <PairingEntity>(entity); } await _db.SaveChangesAsync(); return(entity); }
public async Task <ProfileImageEntity> UpsertImage(ProfileImageEntity entity) { var image = await GetImage(entity.Id); if (image == null) { _db.Add(entity); } else { _db.Update(entity); } await _db.SaveChangesAsync(); return(entity); }
public async Task <MatchEntity> UpsertMatch(MatchEntity entity) { var existingMatch = await _db.Matches.FindAsync(entity.Id); if (existingMatch == null) { await _db.Matches.AddAsync(entity); } else { _db.MatchContactPreferences.UpdateRange(entity.MatchContactPreferences); _db.Matches.Update(entity); } await _db.SaveChangesAsync(); return(entity); }