public static async Task<Activity> GetActivityAsync(this IContext db, int jobId) { var item = await db.Activity.FindAsync(jobId); if(item == null) { item = new Activity() { JobId = jobId }; db.Activity.Add(item); await db.SaveChangesAsync(); } return item; }
public static Activity GetActivity(this IContext db, int jobId) { var item = db.Activity.Find(jobId); if(item == null) { item = new Activity() { JobId = jobId }; db.Activity.Add(item); db.SaveChanges(); } return item; }