public ServiceSyncArticuloEntity SynchronizeArticuloDACS(ItrisAuthenticateEntity authenticateEntity, string lastUpdate) { //Listas CUD en DB_DACS ServiceSyncArticuloEntity serviceArticuloEntity = new ServiceSyncArticuloEntity(); serviceArticuloEntity.ListaCreate = new List <ARTICULO>(); serviceArticuloEntity.ListaUpdate = new List <ARTICULO>(); serviceArticuloEntity.ListaDelete = new List <ARTICULO>(); try { List <ARTICULO> listaArticulosItris = new List <ARTICULO>(); ItrisArticuloBusiness itrisArticuloBusiness = new ItrisArticuloBusiness(authenticateEntity); ItrisArticuloResponse itrisArticuloResponse = Task.Run(async() => await itrisArticuloBusiness.GetLastUpdate(lastUpdate)).GetAwaiter().GetResult(); List <ARTICULO> listaServiceArticulo = this.Read() as List <ARTICULO>; //Comparo elemento por elemento para chequear los insert y actualizaciones foreach (var objItris in itrisArticuloResponse.data) { var articulo = listaServiceArticulo.Where(a => a.ID == objItris.ID).SingleOrDefault(); if (articulo != null) { if (!ArticulosIguales(articulo, objItris)) { ActualizoArticulo(articulo, objItris); serviceArticuloEntity.ListaUpdate.Add(articulo); } } else { serviceArticuloEntity.ListaCreate.Add(CreoNuevoArticulo(objItris)); } } //Obtengo los elementos que tengo que eliminar en la bd DACS //foreach (var objService in listaServiceArticulo) //{ // var objDelete = itrisArticuloResponse.data.Where(a => a.ID == objService.ID).SingleOrDefault(); // if (objDelete == null) // serviceArticuloEntity.ListaDelete.Add(objService); //} PersistirListas(serviceArticuloEntity); } catch (Exception ex) { throw ex; } return(serviceArticuloEntity); }
public async Task <ItrisArticuloResponse> Get() { try { itrisArticuloResponse = await itrisArticuloRepository.Get(itrisAuthenticateEntity.GetUrl()); } catch (Exception ex) { throw ex; } return(itrisArticuloResponse); }
public async Task <ItrisArticuloResponse> GetLastUpdate(string lastUpdate) { try { itrisArticuloResponse = await itrisArticuloRepository.Get(itrisAuthenticateEntity.GetApi3FilterDateLastUpdate(lastUpdate)); return(itrisArticuloResponse); } catch (Exception ex) { throw ex; } }