예제 #1
0
        public async Task <ActionResult <MovieResponse> > PostActor(long movieId, AddActorRequest addActorRequest)
        {
            var movie = await _context.Movies.Include(movie => movie.Comments).FirstOrDefaultAsync(movie => movie.Id == movieId);

            var        actor      = ActorMapper.mapFormAddActorRequestToActor(addActorRequest);
            var        foundActor = _context.Actor.Where(actor => actor.Name == addActorRequest.Name).ToArray();
            MovieActor movieActor = new MovieActor();

            if (foundActor.Count() == 1)
            {
                actor              = foundActor.First();
                movieActor.Actor   = actor;
                movieActor.ActorId = actor.Id;
            }
            else
            {
                movieActor.Actor   = actor;
                movieActor.ActorId = actor.Id;
            }
            movieActor.Movie   = movie;
            movieActor.MovieId = movie.Id;
            movie.Actors.Add(movieActor);
            actor.Movies.Add(movieActor);
            _context.MovieActors.Add(movieActor);
            await _context.SaveChangesAsync();

            return(Ok(MovieMapper.mapFromMovieToMovieResponse(movie)));
        }
예제 #2
0
        public GameScene(GraphicsDevice graphicsDevice, ContentManager content, TileMap tileMap, Vector2 sceneryOffSet)
        {
            this.content        = content;
            this.graphicsDevice = graphicsDevice;
            this.sceneryOffSet  = sceneryOffSet;
            cameraManager       = new CameraManager();
            camera              = new Camera(Vector2.Zero, new Vector2(this.Width, this.Height), new Vector2(50000, 50000));
            this.tileMap        = tileMap;
            this.tileMap.Camera = camera;
            actorManager        = new ActorManager();
            gateMapper          = new ActorMapper(content, this.tileMap);
            actorManager.Reset();
            player        = new Actors.Player(actorManager, tileMap, camera, new Vector2(-100, -100), content.Load <Texture2D>(@"Textures/player"), 25.0f, 16, 16, 15, 15);
            chasingCamera = new ChasingCamera(player.location, camera, 2.0f);
            cameraManager.SetCameraScript(chasingCamera);
            IsCameraFree       = false;
            this.weaponManager = new WeaponManager();
            //cameraManager.AddCameraHandler(new Rotater(0.0f, MathHelper.PiOver2, 8));
            cameraManager.AddCameraHandler(new Zoomer(1.0f, 1.0f, 0.5f, 0.01f));

            UpdateRenderTarget();
            this.sceneryOffSet = sceneryOffSet;
            PuzzleEngineAlpha.Resolution.ResolutionHandler.Changed += ResetSizes;
            this.tileMap.NewMap += NewMapHandling;
            particleManager      = new ParticleManager(content, this.camera);
        }
예제 #3
0
        public async Task <ActionResult <ActorResponse> > DeleteActor(long actorId)
        {
            var actor = _context.Actor.Include(actor => actor.Movies).FirstOrDefault(actor => actor.Id == actorId);

            _context.Actor.Remove(actor);
            await _context.SaveChangesAsync();

            return(Ok(ActorMapper.mapFormActorToActorResponse(actor)));
        }
예제 #4
0
        public async Task <ActionResult <ActorResponse> > PostActor(AddActorRequest addActorRequest)
        {
            Actor actor = ActorMapper.mapFormAddActorRequestToActor(addActorRequest);

            _context.Actor.Add(actor);
            await _context.SaveChangesAsync();

            return(Ok(ActorMapper.mapFormActorToActorResponse(actor)));
        }
예제 #5
0
        public Task AddOrUpdateAsync(Actor actor)
        {
            ArgumentNullException.ThrowIfNull(actor, nameof(actor));

            var actorDocument = ActorMapper.Map(actor);

            return(_repositoryContainer
                   .Container
                   .UpsertItemAsync(actorDocument));
        }
예제 #6
0
        public async Task <Actor> Put(Guid id, [FromBody] Actor actor)
        {
            var entity = _actorService.Get(id);

            ActorMapper.Map(actor, entity);
            entity = _actorService.Update(entity);

            return(await ActorMapper.Map(entity)
                   .AddLinks(_linksService));
        }
예제 #7
0
        public async Task <Actor> Post([FromBody] Actor actor)
        {
            var entity = ActorMapper.Map(actor);

            entity = _actorService.Insert(entity);


            return(await ActorMapper.Map(entity)
                   .AddLinks(_linksService));
        }
예제 #8
0
        public ActorFacadeTest()
        {
            var dbContextFactory = new DbContextInMemoryFactory(nameof(ActorFacadeTest));
            var unitOfWork       = new UnitOfWork(dbContextFactory);

            repository = new Repository <ActorEntity>(unitOfWork);
            mapper     = new ActorMapper();

            facadeTestUnit = new ActorFacade(unitOfWork, repository, mapper);
        }
예제 #9
0
        public async Task <Actor?> GetActorAsync(ExternalActorId externalActorId)
        {
            ArgumentNullException.ThrowIfNull(externalActorId, nameof(externalActorId));

            var query =
                from actor in _repositoryContainer.Container.GetItemLinqQueryable <CosmosActor>()
                where actor.ExternalId == externalActorId.Value.ToString()
                select actor;

            var actorDocument = await query
                                .AsCosmosIteratorAsync()
                                .SingleOrDefaultAsync()
                                .ConfigureAwait(false);

            return(actorDocument != null?ActorMapper.Map(actorDocument) : null);
        }
예제 #10
0
        public async Task DeleteAsync(Actor actor)
        {
            ArgumentNullException.ThrowIfNull(actor, nameof(actor));

            var actorDocument = ActorMapper.Map(actor);

            try
            {
                await _repositoryContainer
                .Container
                .DeleteItemAsync <CosmosActor>(actorDocument.Id, new PartitionKey(actorDocument.Id))
                .ConfigureAwait(false);
            }
            catch (CosmosException ex) when(ex.StatusCode == HttpStatusCode.NotFound)
            {
                // Nothing to do.
            }
        }
예제 #11
0
        public ActionResult Edit(Actor actor)
        {
            Actor actorToUpdate = this.session.Get <Actor>(actor.Id);

            if (actor == null)
            {
                return(this.HttpNotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    var roleIds  = this.Request.Form.GetValues("MovieRoleId");
                    var titles   = this.Request.Form.GetValues("MovieRoleTitle");
                    var movieIds = this.Request.Form.GetValues("MovieRoleMovie");

                    if (titles != null || movieIds != null)
                    {
                        for (int index = 0; index < titles.Length; ++index)
                        {
                            actor.MovieRoles.Add(new MovieRole
                            {
                                Id    = int.Parse(roleIds[index]),
                                Actor = actor,
                                Title = titles[index],
                                Movie = session.Get <Movie>(int.Parse(movieIds[index]))
                            });
                        }
                    }
                    ActorMapper.MapFromView(actor, actorToUpdate, session);
                    this.session.Transaction.Commit();
                    return(RedirectToAction("Index"));
                }

                catch (Exception ex)
                {
                    this.ModelState.AddModelError("", "Error updating actor: " + ex.ToString());
                }
            }
            ViewBag.Movies = this.session.Query <Movie>();
            return(View(actor));
        }
예제 #12
0
        public async Task <ActionResult <List <ActorResponse> > > GetActors(long movieId)
        {
            var movie = await _context.Movies
                        .Include(movie => movie.Comments)
                        .Include(movie => movie.Actors)
                        .FirstOrDefaultAsync(movie => movie.Id == movieId);

            var movieActors = await _context.MovieActors
                              .Where(movieActor => movieActor.MovieId == movieId)
                              .Include(movie => movie.Movie)
                              .Include(actor => actor.Actor)
                              .ToListAsync();

            var actors = new List <Actor>();

            foreach (var movieActor in movieActors)
            {
                actors.Add(movieActor.Actor);
            }

            return(Ok(ActorMapper.mapFormActorToActorResponse(actors)));
        }
예제 #13
0
 public async Task <Actor> Get(Guid id)
 {
     return(await ActorMapper.Map(_actorService.Get(id))
            .AddLinks(_linksService));
 }
예제 #14
0
 public async Task <IEnumerable <Actor> > Get()
 {
     return(await _actorService.Get()
            .Select(entity => ActorMapper.Map(entity))
            .AddLinks(_linksService));
 }