Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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 }));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 public MediaDetail(MediaDetailViewModel viewModel)
 {
     InitializeComponent();
     GetType(media.type);
     BindingContext = this.BindingContext = viewModel;
 }