public DetailsController(DetailsWrapper <DD, DS, HD> header) : this() { _header = header; _header.DetSet.AllowEdit = true; _Grid.DataSource = _header.DetSet; }
public IActionResult AddTipLike(DetailsWrapper fromForm, int RecipeId) { RegisterUser fromLogin = HttpContext.Session.GetObjectFromJson <RegisterUser>("LoggedInUser"); if (ModelState.IsValid) { dbContext.Add(fromForm.Like); dbContext.SaveChanges(); return(Redirect($"details/{RecipeId}")); } else { Recipe ThisRecipe = Enumerable.Reverse(dbContext.Recipes .Include(r => r.IngredientList) .Include(r => r.StepList) .Include(r => r.Tips) .ThenInclude(t => t.User) .Include(r => r.Tips) .ThenInclude(t => t.Comments) .Include(r => r.Tips) .ThenInclude(t => t.Likes)) .FirstOrDefault(r => r.RecipeId == RecipeId); DetailsWrapper DetailsWrapper = new DetailsWrapper(); DetailsWrapper.Recipe = ThisRecipe; DetailsWrapper.User = fromLogin; return(View("RecipeDetails", DetailsWrapper)); } }
public IActionResult RemoveTipLike(DetailsWrapper fromForm, int RecipeId) { Like ToDelete = dbContext.Likes.FirstOrDefault(l => l.UserTipId == fromForm.Like.UserTipId && l.TipId == fromForm.Like.TipId); dbContext.Remove(ToDelete); dbContext.SaveChanges(); return(Redirect($"details/{RecipeId}")); }
public IActionResult MovieDetails(int movie_id) { int?UserId = HttpContext.Session.GetInt32("UserId"); if (UserId == null) { return(RedirectToAction("Login", "LogReg")); } else { Movie movie = GetMovie(movie_id); User user = _context.Users.FirstOrDefault(u => u.UserId == UserId); var client = _clientFactory.CreateClient("BaseAddress"); var response = client.GetAsync($"/3/movie/{movie_id}/credits?api_key=002100dd35529be2881e0dbc97008958").Result; var json = response.Content.ReadAsStringAsync().Result; var deserialize = JsonConvert.DeserializeObject <AllCredits>(json); var sclient = _clientFactory.CreateClient("BaseAddress"); var sresponse = sclient.GetAsync($"/3/movie/{movie_id}/similar?api_key=002100dd35529be2881e0dbc97008958&language=en-US&page=1").Result; var sjson = sresponse.Content.ReadAsStringAsync().Result; var sdeserialize = JsonConvert.DeserializeObject <SearchResult>(sjson); var vclient = _clientFactory.CreateClient("BaseAddress"); var vresponse = vclient.GetAsync($"/3/movie/{movie_id}/videos?api_key=002100dd35529be2881e0dbc97008958&language=en-US").Result; var vjson = vresponse.Content.ReadAsStringAsync().Result; var vdeserialize = JsonConvert.DeserializeObject <AllVideos>(vjson); DetailsWrapper WMod = new DetailsWrapper(); WMod.User = user; WMod.Movie = movie; WMod.Credits = deserialize; WMod.SimilarMovies = sdeserialize; WMod.Videos = vdeserialize; return(View("MovieDetails", WMod)); } }
public IActionResult RecipeDetails(int RecipeId) { RegisterUser fromLogin = HttpContext.Session.GetObjectFromJson <RegisterUser>("LoggedInUser"); RegisterUser RegisterUser = dbContext.Users .Include(u => u.TipLikes) .FirstOrDefault(u => u.UserId == fromLogin.UserId); Recipe ThisRecipe = Enumerable.Reverse(dbContext.Recipes .Include(r => r.IngredientList) .Include(r => r.StepList) .Include(r => r.Tips) .ThenInclude(t => t.User) .Include(r => r.Tips) .ThenInclude(t => t.Comments) .Include(r => r.Tips) .ThenInclude(t => t.Likes)) .FirstOrDefault(r => r.RecipeId == RecipeId); DetailsWrapper DetailsWrapper = new DetailsWrapper(); DetailsWrapper.Recipe = ThisRecipe; DetailsWrapper.User = RegisterUser; return(View(DetailsWrapper)); }