コード例 #1
0
        public Entity.Person AddActor(Model.RequestModel.AddPerson actor)
        {
            var newActor = AutoMapper.Mapper.Map <Entity.Person>(actor);

            newActor.PersonType = Helpers.PersonType.Actor;
            _context.People.Add(newActor);
            if (_context.SaveChanges() > 0)
            {
                return(newActor);
            }
            return(null);
        }
コード例 #2
0
        public Entity.Movie AddMovie(Model.RequestModel.AddMovie movie)
        {
            var newMovie = AutoMapper.Mapper.Map <Entity.Movie>(movie);

            _context.Movies.Add(newMovie);

            foreach (Guid actorId in movie.Actors)
            {
                var actorMovieMap = new ActorMovieMap()
                {
                    MovieId = newMovie.Id,
                    ActorId = actorId
                };
                _context.ActorMovieMap.Add(actorMovieMap);
            }

            if (_context.SaveChanges() > 0)
            {
                return(newMovie);
            }
            return(null);
        }
コード例 #3
0
 public bool Save()
 {
     return(_context.SaveChanges() > 0 ? true: false);
 }