public async Task <HttpResponseMessage> Play([FromUri] string value) { try { //get user id and movie id from session in database var s = await Database.User.Get.BySession(value); Session_Play sp = new Session_Play(); Session_Guest sg = new Session_Guest(); string movieId = ""; Movie_Data movie; if (s is Session_Play) { sp = (Session_Play)s; movieId = sp.movie_id; movie = await Database.Movie.Get.ByGuidAndChangeCounter(sp.movie_id, true); } else { sg = (Session_Guest)s; movieId = sg.movie_id; movie = await Database.Movie.Get.ByGuidAndChangeCounter(sg.movie_id, true); } if (sp != null || sg != null && movieId != null) { await History.Create(History.Type.User, new History_User() { user_action = "User requesting to watch movie: " + value, user_datetime = DateTime.Now, user_id = sp.user_id, user_movie = movie.Movie_Info.title, user_type = "Status -> User Request -> Movie" }); //Getting movie from DB if (movie != null && movie.enabled) { await History.Create(History.Type.User, new History_User() { user_action = "Movie " + value + " is being served.", user_datetime = DateTime.Now, user_id = sp.user_id, user_movie = movie.Movie_Info.title, user_type = "Status -> Movie -> start send" }); //streaming content to client return(await Streaming.Content(movie, base.Request.Headers.Range)); } throw new HttpResponseException(HttpStatusCode.NotFound); } throw new HttpResponseException(HttpStatusCode.Forbidden); } catch (System.Web.HttpException ex) { await History.Create(History.Type.API, new History_API() { api_action = "Exception caught on Play() -> " + ex.Message, api_datetime = DateTime.Now, api_type = "Exception thrown -> Play" }); throw new HttpResponseException(HttpStatusCode.Conflict); } }