using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using LCU.Shared.Collections.RepoApiLib.Models; using LCU.Shared.Collections.RepoApiLib.Persistence; using Microsoft.EntityFrameworkCore; namespace LCU.Shared.Collections.RepoApiLib.Repositories { public class SavedLocationRepository : BaseRepository, ISavedLocationRepository { public SavedLocationRepository(AppDbContext context) : base(context) { } public async Task> ListAsync() { return await _context.SavedLocations.ToListAsync(); } public async Task FindByIdAsync(int id) { return await _context.SavedLocations.Where(savedLocation => savedLocation.ID == id).FirstOrDefaultAsync(); } public async Task AddAsync(SavedLocation savedLocation) { var result = await _context.SavedLocations.AddAsync(savedLocation); return result.Entity; } public void Update(SavedLocation savedLocation) { _context.SavedLocations.Update(savedLocation); } public void Remove(SavedLocation savedLocation) { _context.Remove(savedLocation); } } }