public Task AddBodyWeightAsync(BodyWeight bodyWeight) { if (bodyWeight == null) { throw new ArgumentNullException(nameof(bodyWeight)); } return(Implementation()); async Task Implementation() { await dbContext.BodyWeights.AddAsync(bodyWeight); await dbContext.SaveChangesAsync(); } }
public Task UpsertUserProfile(UserProfile userProfile) { if (userProfile == null) { throw new ArgumentNullException(nameof(userProfile)); } return(Implementation()); async Task Implementation() { await bodyInfoContext.UserProfiles.Upsert(userProfile) .On(p => p.ID) .WhenMatched(p => new UserProfile { Height = userProfile.Height, BirthDate = userProfile.BirthDate }) .RunAsync(); await bodyInfoContext.SaveChangesAsync(); } }