예제 #1
0
        public async Task <IActionResult> AddToWLAsync([FromHeader] string Authorization, [FromBody] UserCred userCred)
        {
            string email = tokenObj.GetNameClaims(Authorization);
            int    movie = userCred.MovieId;
            Dictionary <string, string> dictionary = new Dictionary <string, string>();


            if (email == "" || movie == 0)
            {
                dictionary.Add("Message:", "Not Found");
                dictionary.Add("Description:", "Please enter all fields");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            if (await WatchListMethods.IsInList(email, movie) == true)
            {
                dictionary.Add("Message:", "Not Found");
                dictionary.Add("Description:", "Please enter all fields");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }



            if (UserMethods.getUser(email) == null)
            {
                dictionary.Add("Message:", "Not Found");
                dictionary.Add("Description:", "User not found");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            MovieFirebase retMov = await MovieMethods.GetMovie(movie);

            if (retMov.id == 0)
            {
                dictionary.Add("Message:", " Not Found");
                dictionary.Add("Description:", "Movie Not Found");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            if (!(await WatchListMethods.insertInWLAsync(email, movie)))
            {
                dictionary.Add("Message:", "NotFound");
                dictionary.Add("Description:", "Something went wrong");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            return(Ok(JsonConvert.SerializeObject(retMov, Formatting.Indented)));
        }
예제 #2
0
        public async Task <IActionResult> getMovieAsync(int id)
        {
            MovieFirebase movie = await MovieMethods.GetMovie(id);

            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            if (movie.id == 0)
            {
                dictionary.Add("Message:", "Not Found");
                dictionary.Add("Description:", "Movie not found");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            string json = JsonConvert.SerializeObject(movie, Formatting.Indented);

            return(Ok(json));
        }