using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using SharedLibrary.Database; namespace SharedLibrary.Services { public class GenericService : Interfaces.IEntityService { public async Task Create(T entity) { using (var context = new DatabaseContext()) { var dbSet = context.Set(entity.GetType()); T addedEntity = (T)dbSet.Add(entity); await context.SaveChangesAsync(); return addedEntity; } } public Task CreateProxy() { throw new NotImplementedException(); } public Task Delete(T entity) { throw new NotImplementedException(); } public Task> Find(Func expression) { throw new NotImplementedException(); } public async Task Get(int entityID) { using (var context = new DatabaseContext()) { var dbSet = context.Set(typeof(T)); return (T)(await dbSet.FindAsync(entityID)); } } public async Task Get(params object[] entityKeys) { using (var context = new DatabaseContext()) { var dbSet = context.Set(typeof(T)); return (T)(await dbSet.FindAsync(entityKeys)); } } public Task GetUnique(string entityProperty) { throw new NotImplementedException(); } public Task Update(T entity) { throw new NotImplementedException(); } } }