public ActionResult GetEventsBySeries([FromRoute] int id) { var db = new GPCalAPIContext(); return(Ok(db.Events .Include(i => i.Series).Where(w => w.SeriesId == id))); }
public ActionResult GetEventsByUser() { var db = new GPCalAPIContext(); var userId = User.Claims.First(f => f.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier").Value; var userSeriesId = db.UserPref .Include(i => i.Series) .Where(w => w.UserId == userId) .Select(s => s.SeriesId); var rv = db.Events .Include(i => i.Series) .Where(w => userSeriesId.Any(a => a == w.SeriesId)) .OrderBy(o => o.DateAndTime) .Select(s => new UserSeries(s, s.Series)); return(Ok(rv)); // return Ok(db.UserPref // .Include(i => i.Series) // .Include(i => i.Series.Events) // .Where(w => w.UserId == userId) // .ToList() // .SelectMany(s => s.Series.Events.Select(ent => new UserSeries(ent, s.Series)))); //.OrderBy(o => o.EventTime)); }
public ActionResult GetSeriesByUser() { var db = new GPCalAPIContext(); var userId = User.Claims.First(f => f.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier").Value; return(Ok(db.UserPref .Where(w => w.UserId == userId) )); }
public ActionResult <UserPref> Delete([FromRoute] int seriesId) { var db = new GPCalAPIContext(); var userId = User.Claims.First(f => f.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier").Value; var currentPref = db.UserPref.FirstOrDefault(f => f.UserId == userId && f.SeriesId == seriesId); db.UserPref.Remove(currentPref); db.SaveChanges(); return(Ok(new { currentPref, seriesId })); }
public ActionResult <UserPref> Post([FromBody] UserPref followed) { var db = new GPCalAPIContext(); var userId = User.Claims.First(f => f.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier").Value; followed.UserId = userId; db.UserPref.Add(followed); db.SaveChanges(); return(Ok(followed)); }
public ActionResult GetSeries() { var db = new GPCalAPIContext(); return(Ok(db.Series)); }
public ActionResult GetEvents() { var db = new GPCalAPIContext(); return(Ok(db.Events.Include(i => i.Series))); }