added controller stub. before changing idataaccess to abstract class

This commit is contained in:
2020-10-15 07:07:32 -04:00
parent 1cd994b074
commit ec52a8233a
10 changed files with 73 additions and 56 deletions

View File

@ -1,11 +1,12 @@
using System;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace COA.EnterpriseServices.DataAccess.EntityFramework
{
public class EntityDataAccess<T> : IDataAccess<T> where T : class, IRecord
public class EntityDataAccess<T> : IDataAccess<T> where T : class, IRecord, new()
{
public bool Add(T item)
{
@ -23,7 +24,23 @@ namespace COA.EnterpriseServices.DataAccess.EntityFramework
{
using (var context = new QuickBaseContext())
{
context.Entry(item);
var entry = context.Entry(item);
entry.State = EntityState.Modified;
context.SaveChanges();
}
return true;
}
public bool Update(int id, Action<T> update)
{
using (var context = new QuickBaseContext())
{
var item = context.Set<T>().FirstOrDefault(e => e.Id == id);
update(item);
context.SaveChanges();
}