42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
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<IEnumerable<SavedLocation>> ListAsync()
|
|
{
|
|
return await _context.SavedLocations.ToListAsync();
|
|
}
|
|
|
|
public async Task<SavedLocation> FindByIdAsync(int id)
|
|
{
|
|
return await _context.SavedLocations.Where(savedLocation => savedLocation.ID == id).FirstOrDefaultAsync();
|
|
}
|
|
|
|
public async Task<SavedLocation> 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);
|
|
}
|
|
|
|
}
|
|
}
|