public SetRecord CreateOrUpdateSetRecord(SetRecord setRecord) { using (var db = new WorkoutDb()) { if (db.SetRecords.Any(x => x.SetRecordId == setRecord.SetRecordId)) { db.Update(setRecord); } else { db.Add(setRecord); } db.SaveChanges(); return(setRecord); } }