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)); }