Пример #1
0
        public async Task <ActionResult> AddMovie(MovieDto movieDto)
        {
            bool rez = await _movieContext.Movies.AnyAsync(x => x.MovieName == movieDto.MovieName);

            if (rez)
            {
                return(BadRequest("Movie already exists"));
            }

            var movie = new AppMovie
            {
                MovieName = movieDto.MovieName,
                Year      = movieDto.Year,
                runtime   = movieDto.runtime,
                genres    = movieDto.genres,
                summary   = movieDto.summary,
                image     = movieDto.image,
                torrent   = movieDto.torrent
            };

            _movieContext.Movies.Add(movie);
            var result = await _movieContext.SaveChangesAsync();

            if (result > 0)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest("Movie not saved to database"));
            }
        }
Пример #2
0
 public async Task <ActionResult> EditMovie(AppMovie appMovie)
 {
     _movieContext.Entry(appMovie).State = EntityState.Modified;
     if (await _movieContext.SaveChangesAsync() > 0)
     {
         return(Ok());
     }
     return(BadRequest("Failed to update Movie!"));
 }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        AppFacade.Ins.AddListener(AppEvent.appLog, UpdateTips);         //debug重定向
        AppFacade.Ins.AddListener(AppEvent.resLoadOver, OnResLoadOver); //监听资源更新结果
        AppFacade.Ins.StartUp();                                        //启动框架

        startMovie = new AppMovie(startMovieTime);                      //播放开始动画
        startMovie.Play(() =>
        {
            isMovieOver = true;
            OnLoadOver();
        });
    }
Пример #4
0
        public async Task <ActionResult> DeleteMovie(MovieDeleteDTO movieDelete)
        {
            AppMovie movie = await _movieContext.Movies.FindAsync(movieDelete.id);

            if (movie == null)
            {
                return(NotFound("movie not found"));
            }
            _movieContext.Remove(movie);
            if (await _movieContext.SaveChangesAsync() > 0)
            {
                return(Ok());
            }
            return(BadRequest("Error deleting object"));
        }
Пример #5
0
        public async Task <ActionResult <AppMovie> > CreateMovie(MovieUpdateDto movieUpdate)
        {
            if (await MovieExists(movieUpdate.MovieId))
            {
                return(await UpdateMovie(movieUpdate));
            }
            else
            {
                var movie = new AppMovie
                {
                    MovieName = movieUpdate.MovieName.ToLower(),
                    Like      = movieUpdate.Like,
                    Dislike   = movieUpdate.Dislike,
                    MovieId   = movieUpdate.MovieId
                };
                _context.AppMovies.Add(movie);
                await _context.SaveChangesAsync();

                return(Ok(movie));
            }
        }
Пример #6
0
        public async Task <ActionResult <MovieDto> > RemoveMovie(MovieDto movieDto)
        {
            if (!await MovieExists(movieDto.Title))
            {
                return(BadRequest("Movie does not exists"));
            }

            var movie = new AppMovie
            {
                Title         = movieDto.Title.ToLower(),
                ReleaseYear   = movieDto.ReleaseYear,
                MovieCategory = movieDto.MovieCategory
            };

            _context.Movies.Remove(movie);
            await _context.SaveChangesAsync();

            return(new MovieDto
            {
                Title = movieDto.Title.ToLower(),
                ReleaseYear = movieDto.ReleaseYear,
                MovieCategory = movieDto.MovieCategory
            });
        }