private void SyncSupply() { ArrayList ArrayListSupply = new ArrayList(); Model.Local.Supply Supply; Model.Sage.F_DEPOTRepository F_DEPOTRepository = new Model.Sage.F_DEPOTRepository(); List <Model.Sage.F_DEPOT> ListDepot = F_DEPOTRepository.ListOrderByIntitule(); Model.Local.SupplyRepository SupplyRepository = new Model.Local.SupplyRepository(); foreach (Model.Sage.F_DEPOT Depot in ListDepot) { Supply = new Model.Local.Supply(); if (SupplyRepository.ExistSage(Depot.DE_No == null ? 0 : Depot.DE_No)) { Supply = SupplyRepository.ReadSage(Depot.DE_No == null ? 0 : Depot.DE_No); Supply.Sup_Name = Depot.DE_Intitule; SupplyRepository.Save(); } else { Supply.Sup_Name = Depot.DE_Intitule; Supply.Sup_Active = false; Supply.Sag_Id = Depot.DE_No == null ? 0 : Depot.DE_No; SupplyRepository.Add(Supply); } ArrayListSupply.Add(Depot.DE_No); } List <Model.Local.Supply> ListSupply = SupplyRepository.List(); foreach (Model.Local.Supply SupplyContains in ListSupply) { if (ArrayListSupply.Contains(SupplyContains.Sag_Id) == false) { SupplyRepository.Delete(SupplyContains); } } }
public void Delete(Supply Obj) { this.DBLocal.Supply.DeleteOnSubmit(Obj); this.Save(); }
public void Add(Supply Obj) { this.DBLocal.Supply.InsertOnSubmit(Obj); this.Save(); }