Last active
December 14, 2018 21:28
-
-
Save explorer14/bba6f961541346db0e409cc82c2a811d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PeriodRepository : IPeriodRepository | |
{ | |
// at this point, I have already created my DbContext which I will | |
// then use to generate the database by running EF Code First commands | |
private PeriodContext context; | |
public PeriodRepository(PeriodContext context) | |
{ | |
this.context = context; | |
} | |
public async Task AddAsync(Period domainObject) | |
{ | |
this.context.Set<Period>().Add(domainObject); | |
await this.context.SaveChangesAsync(); | |
} | |
public async Task<IEnumerable<Period>> GetListAsync( | |
Expression<Func<Period, bool>> predicate) | |
{ | |
return await this.context.Set<Period>() | |
.Include("Pots.Expenses").Where(predicate).ToListAsync(); | |
} | |
public async Task<Period> GetOneAsync(Guid id) | |
{ | |
return await this.context.Set<Period>() | |
.FirstOrDefaultAsync(x => x.Id == id); | |
} | |
public async Task UpdateAsync(Period updatedEntity) | |
{ | |
this.context.Update(updatedEntity); | |
await this.context.SaveChangesAsync(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment