public MediaDetailPage(MediaDetails media) { Title = ApplicationResource.PageMediaDetailTitle; BindingContext = new MediaDetailViewModel(this.Navigation, media); var image = new CachedImage { Aspect = Aspect.AspectFill }; image.SetBinding(CachedImage.SourceProperty, "MediaFilePath"); var deleteToolbarItem = new ToolbarItem() { Text = "Delete" }; deleteToolbarItem.Command = new Command(async() => await PromptDeleteMedia()); //deleteToolbarItem.SetBinding(ToolbarItem.CommandProperty, new Binding("DeleteMediaCommand")); ToolbarItems.Add(deleteToolbarItem); var layout = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Children = { image } }; Content = layout; }
public async Task <IActionResult> Review(int Id, MediaDetailViewModel vm) { _dbContext.Reviews.Add(new Review() { UserId = User.FindFirstValue(ClaimTypes.NameIdentifier), Comment = vm.Comment, PublishedDate = DateTime.Now, MediaId = Id, UserScore = 5 }); await _dbContext.SaveChangesAsync(); return(RedirectToAction("Detail", new { Id = Id })); }
public async Task <IActionResult> Detail(int Id) { Media mediaToDetail = await _dbContext.medias.Include(x => x.Category).FirstOrDefaultAsync(x => x.Id == Id); var reviews = await _dbContext.Reviews.Where(x => x.MediaId == Id).ToListAsync(); MediaDetailViewModel vm = new MediaDetailViewModel() { Id = mediaToDetail.Id, Category = mediaToDetail.Category.Name, Title = (string)mediaToDetail.Title, Description = (string)mediaToDetail.Description, Creator = (string)mediaToDetail.Creator, Date = (DateTime)mediaToDetail.Date, Rating = (int)mediaToDetail.Rating, PhotoUrl = mediaToDetail.PhotoUrl, Watched = mediaToDetail.Watched, Reviews = reviews }; return(View(vm)); }
public MediaDetail(MediaDetailViewModel viewModel) { InitializeComponent(); GetType(media.type); BindingContext = this.BindingContext = viewModel; }