public ActionResult ObrisiIzWatchLater(WatchLater program) { ISession session = SessionManager.GetSession(); if (session == null) { return(View()); } session.Execute("DELETE FROM \"Watch_later2\" WHERE \"userId\" = '" + program.userId + "' AND \"kanalId\" = '" + program.kanalId + "' AND datum = '" + program.datum + "' AND vreme = '" + program.vreme + "'"); List <WatchLater> programi = new List <WatchLater>(); var data = session.Execute("SELECT * FROM \"Watch_later2\" WHERE \"userId\" = '" + userId + "'"); foreach (var prog in data) { WatchLater p = new WatchLater(); p.userId = prog["userId"] != null ? prog["userId"].ToString() : string.Empty; p.kanalId = prog["kanalId"] != null ? prog["kanalId"].ToString() : string.Empty; p.datum = prog["datum"] != null ? prog["datum"].ToString() : string.Empty; p.vreme = prog["vreme"] != null ? prog["vreme"].ToString() : string.Empty; p.naziv = prog["naziv"] != null ? prog["naziv"].ToString() : string.Empty; p.opis = prog["opis"] != null ? prog["opis"].ToString() : string.Empty; p.tip = prog["tip"] != null ? prog["tip"].ToString() : string.Empty; programi.Add(p); } return(View("WatchLater", programi)); }
public ActionResult WatchLater() { ISession session = SessionManager.GetSession(); if (session == null) { return(View()); } List <WatchLater> programi = new List <WatchLater>(); if (userId != null) { var data = session.Execute("SELECT * FROM \"Watch_later2\" WHERE \"userId\" = '" + userId + "'"); foreach (var prog in data) { WatchLater program = new WatchLater(); program.userId = prog["userId"] != null ? prog["userId"].ToString() : string.Empty; program.kanalId = prog["kanalId"] != null ? prog["kanalId"].ToString() : string.Empty; program.datum = prog["datum"] != null ? prog["datum"].ToString() : string.Empty; program.vreme = prog["vreme"] != null ? prog["vreme"].ToString() : string.Empty; program.naziv = prog["naziv"] != null ? prog["naziv"].ToString() : string.Empty; program.opis = prog["opis"] != null ? prog["opis"].ToString() : string.Empty; program.tip = prog["tip"] != null ? prog["tip"].ToString() : string.Empty; programi.Add(program); } } return(View(programi)); }
public IActionResult PostWatchLater([FromBody] WatchLater watchLater) { movieDbRepository.AddToWatchLater(new WatchLater { MovieId = watchLater.MovieId, UserId = int.Parse(this.User.Claims.First().Value) }); return(Ok()); }
public async Task <bool> AddToWatchLater(long userId, long lessonId) { try { var wl = await Context.WatchLater .Where(w => w.UserId == userId && w.LessonId == lessonId) .SingleOrDefaultAsync(); if (wl == null && userId != 0 && lessonId != 0) { var watch = new WatchLater(userId, lessonId); await Context.WatchLater.AddAsync(watch); } return((await Context.SaveChangesAsync()) > 0); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public void AddToWatchLater(WatchLater watchLater) { _context.WatchLaters.Add(watchLater); _context.SaveChanges(); }