Пример #1
0
        // get : api/Search?q={searchText}
        protected override string ProcessRequest()
        {
            JavaScriptSerializer json = new JavaScriptSerializer();

            try
            {
                var tableMgr = new TableManager();

                // get query string parameters
                var qpParams = HttpUtility.ParseQueryString(this.Request.RequestUri.Query);

                if (string.IsNullOrEmpty(qpParams["q"]))
                {
                    throw new ArgumentException(Constants.API_EXC_SEARCH_TEXT_NOT_EXIST);
                }

                string searchText = qpParams["q"];

                searchText = string.IsNullOrEmpty(searchText) ? string.Empty : searchText.Replace(".", "");

                // get movies by search keyword
                var movie = tableMgr.SearchMovies(searchText);

                // serialize movie list and return
                return json.Serialize(movie);
            }
            catch (Exception ex)
            {
                // if any error occured then return User friendly message with sys  tem error message
                return json.Serialize(new { Status = "Error", UserMessage = Constants.UM_WHILE_SEARCHING_MOVIES, ActualError = ex.Message });
            }
        }
Пример #2
0
        public JsonResult AutoCompleteCountry(string term)
        {
            SetConnectionString();

            var tableMgr = new TableManager();
            var movie = tableMgr.SearchMovies(term);

            var users = (from u in movie
                         where u.Name.ToLower().Contains(term.ToLower())
                         select u.Name).Distinct().ToArray();

            return Json(users, JsonRequestBehavior.AllowGet);
        }
Пример #3
0
        // get : api/Search?search={searchText}
        //protected override string ProcessRequest()
        protected override string ProcessRequest()
        {
            JavaScriptSerializer json = new JavaScriptSerializer();

            var qpParams = HttpUtility.ParseQueryString(this.Request.RequestUri.Query);
            if (string.IsNullOrEmpty(qpParams["term"]))
            {
                throw new ArgumentException("search text is not present");
            }

            string searchText = qpParams["term"];

            var tableMgr = new TableManager();
            var movie = tableMgr.SearchMovies(searchText);

            var users = (from u in movie where u.Name.Contains(searchText)
                         select u.Name).Distinct().ToArray();

            return json.Serialize(users);
        }
Пример #4
0
        public ActionResult Test()
        {
            var connectionString = CloudConfigurationManager.GetSetting("StorageTableConnectionString");
            Trace.TraceInformation("Connection str read");
            ConnectionSettingsSingleton.Instance.StorageConnectionString = connectionString;

            string q = "testsample";
            var tableMgr = new TableManager();

            var movie = tableMgr.GetMovieById(q);
            @ViewBag.MovieEntity = movie;

            var resp = new StringBuilder();
            if (movie != null)
            {
                resp.Append("Movie Name : ");
                resp.Append(movie.Name);

                var reviews = movie.GetReviewIds();
                var reviewList = tableMgr.GetReviewsById(reviews);
                foreach (var reviewEntity in reviewList)
                {
                    resp.Append("\r\n With review -- ");
                    resp.Append(reviewEntity.Value.Review);
                }
            }
            else
            {
                resp.Append("No movie found");
            }

            ViewBag.Message = "You searched for " + q + "and the response you got was: " + resp;

            var movie1 = tableMgr.GetCurrentMovies();
            @ViewBag.MovieEntity = movie1;

            var movie3 = tableMgr.SearchMovies("search text");
            @ViewBag.MovieEntity = movie3;

            TestUpdate();

            return View();
        }