Changed parts of how data project stucture

This commit is contained in:
2019-04-22 22:46:39 +00:00
parent 83385a66c7
commit 49f6ee5542
13 changed files with 23 additions and 99 deletions

View File

@@ -0,0 +1,48 @@
using BrightGlimmer.Data.Domain;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BrightGlimmer.Data.Repositories
{
public class StudentRepository
{
private readonly SqliteContext context;
public StudentRepository(SqliteContext context)
{
this.context = context;
}
public Student Create(Student student)
{
EntityEntry<Student> entry = context.Students.Add(student);
context.SaveChanges();
return entry.Entity;
}
public void Update(Student student)
{
context.SaveChanges();
}
public void Remove(Guid id)
{
context.Students.Remove(GetById(id));
context.SaveChanges();
}
public IQueryable<Student> GetAll()
{
return context.Students;
}
public Student GetById(Guid id)
{
return context.Students.Find(id);
}
}
}