2019-03-06 19:17:36 +00:00
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using api.Models;
|
|
|
|
using api.Data;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace api.Data
|
|
|
|
{
|
|
|
|
public class EventLocsRepository : IEventLocsRepository
|
|
|
|
{
|
|
|
|
public EventLocsRepository(DataContext context)
|
|
|
|
{
|
|
|
|
_context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataContext _context { get; }
|
|
|
|
|
|
|
|
public async Task<EventLoc> GetEventLoc(int id)
|
|
|
|
{
|
|
|
|
var rEventLocs = await _context.EventLocs.FirstOrDefaultAsync(e=>e.Id == id);
|
|
|
|
|
|
|
|
return rEventLocs;
|
|
|
|
}
|
|
|
|
|
2019-03-07 17:33:15 +00:00
|
|
|
public async Task<List<EventLoc>> GetEventLocEvent(int id)
|
2019-03-06 19:17:36 +00:00
|
|
|
{
|
2019-03-07 17:33:15 +00:00
|
|
|
List<EventLoc> eLocs = await _context.EventLocs.ToListAsync();
|
|
|
|
List<EventLoc> rEventLocs = new List<EventLoc>();
|
|
|
|
|
|
|
|
eLocs.ForEach(delegate (EventLoc e){
|
|
|
|
if(e.EventId == id){
|
|
|
|
rEventLocs.Add(e);
|
|
|
|
}
|
|
|
|
});
|
2019-03-06 19:17:36 +00:00
|
|
|
|
|
|
|
return rEventLocs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<EventLoc>> GetEventLocs()
|
|
|
|
{
|
2019-03-16 19:17:19 +00:00
|
|
|
var rEventLocs = await _context.EventLocs.Include(a=>a.Img).ToListAsync();
|
2019-03-06 19:17:36 +00:00
|
|
|
|
|
|
|
return rEventLocs;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|