public ActionResult <WatchingResult> Check([Bind("User_Id", "Media_Id", "Type", "SeekPosition")] NewSeek newSeek)
        {
            String resultText = "";


            //Stopwatch t_sw = new Stopwatch();
            //t_sw.Start();
            MongoWatching query = _ws.Get(newSeek.User_Id.ToString(), newSeek.Media_Id, newSeek.Type);

            //t_sw.Stop();
            //Console.WriteLine("check read takes: " + t_sw.ElapsedMilliseconds + " ms");


            if (query != null)
            {
                resultText = "Watching";
            }
            else
            {
                resultText = "Not Watching";
            }

            WatchingResult watchingResult = new WatchingResult {
                Status = resultText, Watchings = query
            };

            return(watchingResult);
        }
        public async Task <ActionResult <Result> > Seek([Bind("User_Id", "Media_Id", "Type", "SeekPosition")] NewSeek newSeek)
        {
            //To be used while watching, it dosent return a seek position so that it wont update the seek position if there were two persons using the same account on different devices and watching the same media

            Result res = null;

            String resultText;

            //Stopwatch t_sw = new Stopwatch();
            //t_sw.Start();
            MongoWatching query = _ws.Get(newSeek.User_Id.ToString(), newSeek.Media_Id, newSeek.Type);

            //t_sw.Stop();
            //Console.WriteLine("seek read takes: " + t_sw.ElapsedMilliseconds + " ms");
            if (query == null)
            {
                query = new MongoWatching {
                    User_id = newSeek.User_Id.ToString(), Media_Id = newSeek.Media_Id, Type = newSeek.Type, SeekPosition = newSeek.SeekPosition
                };

                //Stopwatch s_sw = new Stopwatch();
                //s_sw.Start();
                _ws.Create(query);
                //s_sw.Stop();
                //Console.WriteLine("seek create takes: " + s_sw.ElapsedMilliseconds + " ms");
                resultText = "Added";
            }
            else
            {
                if (IsCompleted(newSeek.SeekPosition, newSeek.Media_Id, newSeek.Type))
                {
                    //Stopwatch s_sw = new Stopwatch();
                    //s_sw.Start();
                    _ws.Remove(query);
                    //s_sw.Stop();
                    //Console.WriteLine("seek remove takes: " + s_sw.ElapsedMilliseconds + " ms");
                    resultText = "Completed";
                }
                else
                {
                    query.SeekPosition = newSeek.SeekPosition;
                    resultText         = "Watching";
                }
            }

            return(new Result {
                Text = resultText
            });
        }
        public async Task <ActionResult <WatchingResult> > Register([Bind("User_Id", "Media_Id", "Type", "SeekPosition")] NewSeek newSeek)
        {
            String resultText;
            //Stopwatch t_sw = new Stopwatch();
            //t_sw.Start();
            MongoWatching query = _ws.Get(newSeek.User_Id.ToString(), newSeek.Media_Id, newSeek.Type);

            //t_sw.Stop();
            //Console.WriteLine("register read takes: " + t_sw.ElapsedMilliseconds + " ms");
            if (query == null)
            {
                query = new MongoWatching {
                    User_id = newSeek.User_Id.ToString(), Media_Id = newSeek.Media_Id, Type = newSeek.Type, SeekPosition = newSeek.SeekPosition
                };

                //Stopwatch s_sw = new Stopwatch();
                //s_sw.Start();
                _ws.Create(query);
                //s_sw.Stop();
                //Console.WriteLine("register create takes: " + s_sw.ElapsedMilliseconds + " ms");
                resultText = "Added";
            }
            else
            {
                if (IsCompleted(newSeek.SeekPosition, newSeek.Media_Id, newSeek.Type))
                {
                    //var q = from qu in _context.Still_Watchings where qu.User_id == newSeek.User_Id && qu.Media_Id == newSeek.Media_Id && qu.Type == newSeek.Type select qu;
                    //if (q.Count() > 0)
                    //    _context.Still_Watchings.Remove(q.SingleOrDefault());

                    //Stopwatch s_sw = new Stopwatch();
                    //s_sw.Start();
                    _ws.Remove(query);
                    //s_sw.Stop();
                    //Console.WriteLine("register remove takes: " + s_sw.ElapsedMilliseconds + " ms");
                    resultText = "Completed";
                }
                else
                {
                    resultText = "Watching";
                }
            }

            return(new WatchingResult {
                Status = resultText, Watchings = query
            });
        }