コード例 #1
0
        private Film PopulateFilm(CatalogueFilm catalogueFilm)
        {
            var metadataFilm = _metadataService.GetFilm(catalogueFilm.Id);
            var filmReviews  = _reviewsService.GetFilmReviews(catalogueFilm.Id);

            return(Film.Create(catalogueFilm, metadataFilm, filmReviews));
        }
コード例 #2
0
        public async Task UpsertFilm(FilmDto filmDto, string currentUserId)
        {
            var film = filmDto.Id > 0
                       ? await _repository.GetAsync(filmDto.Id)
                       : Film.Create();

            if (!film.IsNew && film.AuthorId != currentUserId)
            {
                throw new DomainException("Только автор может изменять фильм");
            }

            film.Name        = filmDto.Name;
            film.Description = filmDto.Description;
            film.AuthorId    = currentUserId;
            film.Year        = filmDto.Year;
            film.DirectorId  = filmDto.DirectorId;

            if (filmDto.Poster != null)
            {
                // Ideally, thumbnail should be created
                film.PosterUrl = await _fileSaver.Save(film.Name, filmDto.Poster);
            }

            await _repository.UpsertAsync(film);
        }