private static void GetGoodIssues(LOG_CHANGES changeset) { var gi = WebApiClient.GetGoodIssue(changeset.ListVal).Result; if (gi == null) { return; } gi.StateL = LocalStatus.Procesado; var db = ContextFactory.GetDBContext(); var id = Convert.ToInt32(changeset.ListVal); var localId = db.OIGE_GoodsIssues.Include(c => c.IGE1_GoodsIssueDetail) .FirstOrDefault(c => c.IdGoodIssueL == changeset.IdL.Value); var localDE = db.OIGE_GoodsIssues.Include(c => c.IGE1_GoodsIssueDetail) .FirstOrDefault(c => c.DocEntry == id); if (changeset.IdL.HasValue) // C1 { if (localId == null) // C3 { db.OIGE_GoodsIssues.Add(gi); GoodIssuesHelper.SaveTransaction(gi); } else { if (localId.StateL == LocalStatus.Procesado) // C4 { if (localDE == null || localDE.DocEntry != localId.DocEntry) // C5 { db.OIGE_GoodsIssues.Add(gi); GoodIssuesHelper.SaveTransaction(gi); } else { localId.UpdateModelPropertiesFrom(gi); } } else { localId.UpdateModelPropertiesFrom(gi); GoodIssuesHelper.SaveTransaction(gi); } } } else // C2 -- El Idl no contenia un valor { if (localDE == null) { db.OIGE_GoodsIssues.Add(gi); GoodIssuesHelper.SaveTransaction(gi); } } //db.LOG_CHANGES.Add(changeset); changeset.AddChangeset(); }
private static OIGE_GoodsIssues SyncUpload(OIGE_GoodsIssues good) { var result = WebApiClient.AddGoodIssue(good).Result; good.UpdateModelPropertiesFrom(result.Model); good.StateL = LocalStatus.Procesado; result.UpdateEntityVersion(); GoodIssuesHelper.SaveTransaction(good); return(good); }