public async Task <IActionResult> GetWatchlistAsync([FromHeader] string Authorization) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); string email = tokenObj.GetNameClaims(Authorization); if (email == "") { dictionary.Add("Message:", "NotFound"); dictionary.Add("Description:", "Please enter all fields"); return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented))); } if (await UserMethods.getUser(email) == null) { dictionary.Add("Message:", "NotFound"); dictionary.Add("Description:", "User not found"); return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented))); } List <MovieFirebase> wl = await WatchListMethods.GetMoviesAsync(email); if (wl.Count == 0 || wl == null) { dictionary.Add("Message:", "NotFound"); dictionary.Add("Description:", "WatchList is empty"); return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented))); } string json = JsonConvert.SerializeObject(wl, Formatting.Indented); return(Ok(json)); }
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))); }
public async Task <IActionResult> RemoveFromWLAsync([FromHeader] string Authorization, [FromBody] UserCred userCred) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); string email = tokenObj.GetNameClaims(Authorization); int movie = userCred.MovieId; if (await WatchListMethods.IsInList(email, movie) == false) { dictionary.Add("Message:", "Not Found"); dictionary.Add("Description:", "Not Found In List"); return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented))); } if (!(await WatchListMethods.removeFromWLAsync(email, movie))) { dictionary.Add("Message:", "Not Found"); dictionary.Add("Description:", "Something went wrong"); return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented))); } dictionary.Add("Message:", "OK"); dictionary.Add("Description:", "Successfully removed movie from user Watchlist"); return(Ok(JsonConvert.SerializeObject(dictionary))); }