private List<sow_user> GetSowUser(int ServiceProviderId) { List<sow_user> ReturnList = new List<sow_user>(); foreach (SowUser su in SyncClient.GetSowUser(GetFromDate, DateTimeNow, ServiceProviderId)) { sow_user tmp = QuerySowUser(su.Id); Boolean NewValue = false; if (tmp == null) { tmp = new sow_user(); NewValue = true; } tmp.email = su.Email; tmp.Id = su.Id; tmp.name = su.Name; tmp.registeredAt = System.DateTime.Parse(su.RegisteredDat); tmp.username = su.Username; if (NewValue) { dbContext.Set<sow_user>().Add(tmp); } dbContext.SaveChanges(); ReturnList.Add(tmp); } return ReturnList; }