private List<order_item> GetOrderItem(int ServiceProviderId) { List<order_item> ReturnList = new List<order_item>(); foreach (OrderItem OI in SyncClient.GetOrderItem(GetFromDate, DateTimeNow, ServiceProviderId)) { order_item tmp = QueryOrderItem(OI.Id); Boolean NewValue = false; if (tmp == null) { tmp = new order_item(); NewValue = true; } tmp.Id = OI.Id; tmp.addittional_cost = OI.AddCost; tmp.createdAt = System.DateTime.Parse(OI.CreateDat); tmp.final_price = OI.FinalPrice; tmp.final_price_without_tax = OI.FinalPriceWithoutTax; tmp.final_price_with_tax = OI.FinalPriceWithTax; tmp.is_all_inclusive = OI.IsAllIncl; tmp.is_confirmed = OI.IsConfirmed; tmp.is_finished = OI.IsFinished; tmp.option_price = OI.OptionPrice; tmp.order_id = OI.OrderId; tmp.per_item_tax = OI.PerItemTax; tmp.preferred_date_time = System.DateTime.Parse(OI.PreferredDatetime); tmp.price = OI.Price; tmp.quantity = OI.Quantity; tmp.service_id = OI.ServiceId; tmp.service_provider_comment = OI.Comment; tmp.tax = OI.Tax; if (NewValue) { dbContext.Set<order_item>().Add(tmp); } dbContext.SaveChanges(); ReturnList.Add(tmp); } return ReturnList; }