Added DeviceInfo
This commit is contained in:
@@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Navigator.Services
|
|
||||||
{
|
|
||||||
public interface IDataStore<T>
|
|
||||||
{
|
|
||||||
Task<bool> AddItemAsync(T item);
|
|
||||||
bool AddItem(T item);
|
|
||||||
Task<bool> UpdateItemAsync(T item);
|
|
||||||
Task<bool> DeleteItemAsync(string id);
|
|
||||||
bool DeleteItem(string id);
|
|
||||||
Task<T> GetItemAsync(string id);
|
|
||||||
T GetItem(string id);
|
|
||||||
Task<IEnumerable<T>> GetItemsAsync(bool forceRefresh = false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Navigator.Models;
|
|
||||||
|
|
||||||
namespace Navigator.Services
|
|
||||||
{
|
|
||||||
public class MockDataStore : IDataStore<Item>
|
|
||||||
{
|
|
||||||
readonly List<Item> items;
|
|
||||||
|
|
||||||
public MockDataStore()
|
|
||||||
{
|
|
||||||
items = new List<Item>();
|
|
||||||
//items = new List<Item>()
|
|
||||||
// {
|
|
||||||
// new Item { Id = Guid.NewGuid().ToString(), Text = "First item", Description="This is an item description." },
|
|
||||||
// new Item { Id = Guid.NewGuid().ToString(), Text = "Second item", Description="This is an item description." },
|
|
||||||
// new Item { Id = Guid.NewGuid().ToString(), Text = "Third item", Description="This is an item description." },
|
|
||||||
// new Item { Id = Guid.NewGuid().ToString(), Text = "Fourth item", Description="This is an item description." },
|
|
||||||
// new Item { Id = Guid.NewGuid().ToString(), Text = "Fifth item", Description="This is an item description." },
|
|
||||||
// new Item { Id = Guid.NewGuid().ToString(), Text = "Sixth item", Description="This is an item description." }
|
|
||||||
// };
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> AddItemAsync(Item item)
|
|
||||||
{
|
|
||||||
items.Add(item);
|
|
||||||
return await Task.FromResult(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddItem(Item item)
|
|
||||||
{
|
|
||||||
items.Add(item);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> UpdateItemAsync(Item item)
|
|
||||||
{
|
|
||||||
var oldItem = items.Where((Item arg) => arg.Id == item.Id).FirstOrDefault();
|
|
||||||
items.Remove(oldItem);
|
|
||||||
items.Add(item);
|
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> DeleteItemAsync(string id)
|
|
||||||
{
|
|
||||||
var oldItem = items.Where((Item arg) => arg.Id == id).FirstOrDefault();
|
|
||||||
items.Remove(oldItem);
|
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteItem(string id)
|
|
||||||
{
|
|
||||||
var oldItem = items.Where((Item arg) => arg.Id == id).FirstOrDefault();
|
|
||||||
items.Remove(oldItem);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Item> GetItemAsync(string id)
|
|
||||||
{
|
|
||||||
return await Task.FromResult(items.FirstOrDefault(s => s.Id == id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Item GetItem(string id)
|
|
||||||
{
|
|
||||||
return items.FirstOrDefault(s => s.Id==id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<Item>> GetItemsAsync(bool forceRefresh = false)
|
|
||||||
{
|
|
||||||
return await Task.FromResult(items);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user