Commit 4ad2307a by Javier Piris

Modificado método UpdateItemAsync en el local data service

parent 44abf04f
......@@ -97,36 +97,6 @@ namespace inutralia.API
return retVal;
}
public async Task<int?> UpdateItemIngredientAsync<T>(T item, bool isNew = false) where T : IIdentifiableEntity
{
if (isNew)
{
// Elemento nuevo: asignarle Id. Cogemos la lista de ids ...
List<int> idList = GetIdList(item.GetType());
// ... buscamos el máximo y le sumamos 1
//item.Id = (idList.Count < 1) ? 1 : idList.Max () + 1;
// ... añadimos el nuevo id a la lista
idList.Add(item.Id);
// ... y la guardamos
SetIdList(item.GetType(), idList);
}
else if (!AppSettings.Contains(GetItemPath(item)))
{
// El elemento no es nuevo, pero no existe en los datos guardados
return null;
} //endif
// Guardar elemento
AppSettings.AddOrUpdateValue(GetItemPath(item), JsonConvert.SerializeObject(item));
// Retornar su id
return item.Id;
}
public async Task<int?> UpdateItemAsync<T> (T item, bool isNew = false) where T : IIdentifiableEntity
{
if(isNew)
......@@ -135,7 +105,7 @@ namespace inutralia.API
List<int> idList = GetIdList (item.GetType ());
// ... buscamos el máximo y le sumamos 1
item.Id = (idList.Count < 1) ? 1 : idList.Max () + 1;
//item.Id = (idList.Count < 1) ? 1 : idList.Max () + 1;
// ... añadimos el nuevo id a la lista
idList.Add (item.Id);
......
......@@ -349,10 +349,10 @@ namespace inutralia.ViewModels
foreach (Ingredient ing in ingredients.Where(i => listaCompra.Find(sl => sl.FromMenus && sl.Text.Equals(i) && sl.Id.Equals(i)) == null))
{
//await App.LocalData.UpdateItemAsync(new ShoppingList() { FromMenus = true, Select = false, Text = ing }, true);
await App.LocalData.UpdateItemIngredientAsync(new ShoppingList() { FromMenus = true, Select = false, Text = ing.Name, Id = ing.Id }, true);
await App.LocalData.UpdateItemAsync(new ShoppingList() { FromMenus = true, Select = false, Text = ing.Name, Id = ing.Id }, true);
} //endforeach
await App.LocalData.UpdateItemIngredientAsync(_LocalMenu);
await App.LocalData.UpdateItemAsync(_LocalMenu);
IsBusy = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment