Exemplo n.º 1
0
        //acum mutam logica din Controller pe Service.
        //Nu il eliminam dar Controller-ul va apela Service si nu va mai apela UI-ul Service-ul

        public Movie Create(MoviePostModel movie)
        {
            Movie toAdd = MoviePostModel.ToMovie(movie);

            context.Movies.Add(toAdd);
            context.SaveChanges();
            return(toAdd);
        }
Exemplo n.º 2
0
        public UserRoleGetModel Create(UserRolePostModel userRolePostModel)
        {
            UserRole toAdd = UserRolePostModel.ToUserRole(userRolePostModel);

            context.UserRole.Add(toAdd);
            context.SaveChanges();
            return(UserRoleGetModel.FromUserRole(toAdd));
        }
Exemplo n.º 3
0
        public ActionResult DeleteMovie(int Id)
        {
            Movie movie = dbContext.Movies.FirstOrDefault(x => x.Id == Id);

            dbContext.Movies.Remove(movie);
            dbContext.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 4
0
        public Comment Create(CommentPostModel comment, int id)
        {
            Comment toAdd = CommentPostModel.ToComment(comment);
            Movie   movie = context.Movies.FirstOrDefault(e => e.Id == id);

            movie.Comments.Add(toAdd);
            context.SaveChanges();
            return(toAdd);
        }
Exemplo n.º 5
0
        public Comment Create(CommentPostModel comment, User addedBy)
        {
            Comment commentAdd = CommentPostModel.ToComment(comment);

            commentAdd.Owner = addedBy;
            context.Comments.Add(commentAdd);
            context.SaveChanges();
            return(commentAdd);
        }
Exemplo n.º 6
0
        public void Post([FromBody] Movie movie)
        {
            //if (!ModelState.IsValid)
            //{

            //}
            context.Movies.Add(movie);
            context.SaveChanges();
        }
Exemplo n.º 7
0
        public Movie Create(MoviePostModel movie, User addedBy)
        {
            Movie toAdd = MoviePostModel.ToMovie(movie);

            toAdd.Owner = addedBy;      //adaugam persoana care a adaugat acest Movie movie
            context.Movies.Add(toAdd);
            context.SaveChanges();
            return(toAdd);
        }
Exemplo n.º 8
0
        //acum mutam logica din Controller pe Service.
        //Nu il eliminam dar Controller-ul va apela Service si nu va mai apela UI-ul Service-ul

        public Movie Create(MoviePostModel movie, User addedBy)
        {
            Movie toAdd = MoviePostModel.ToMovie(movie);

            toAdd.Owner = addedBy;
            context.Movies.Add(toAdd);
            context.SaveChanges();
            return(toAdd);
        }
Exemplo n.º 9
0
 public IActionResult RegisterMovie(Movie movie)
 {
     if (ModelState.IsValid)
     {
         _context.Movie.Add(movie);
         _context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 10
0
        public ActionResult CreateMovie(Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Movies.Add(movie);
                _context.SaveChanges();
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 11
0
 public ActionResult InsertNewMovie(Movie model)
 {
     if (!ModelState.IsValid)
     {
         return(View("NewMovie", model));
     }
     _context.Movies.Add(model);
     _context.SaveChanges();
     return(View("GetAllMovies", _context.Movies.ToList()));
 }
Exemplo n.º 12
0
 public IActionResult Post([FromBody] Movie movie)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     context.Movies.Add(movie);
     context.SaveChanges();
     return(Ok());
 }
Exemplo n.º 13
0
        public ActionResult Create([Bind(Include = "Id,Title,Director,Studio,StudioAddress,Year,LeadMaleActorId,LeadFemaleActorId")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 14
0
        public Movie Create(MoviePostModel movie, User addedBy)
        {
            Movie toAdd = MoviePostModel.ToMovie(movie);

            movie.DateClosed = null;
            movie.DateAdded  = DateTime.Now;
            toAdd.Owner      = addedBy;
            context.Movies.Add(toAdd);
            context.SaveChanges();
            return(toAdd);
        }
Exemplo n.º 15
0
        public ActionResult Create([Bind(Include = "Id,Name,Age")] Actor actor)
        {
            if (ModelState.IsValid)
            {
                db.Actors.Add(actor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(actor));
        }
Exemplo n.º 16
0
        public ActionResult Create([Bind(Include = "GenreId,GenreName")] Genre genre)
        {
            if (ModelState.IsValid)
            {
                db.Genres.Add(genre);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(genre));
        }
Exemplo n.º 17
0
        public ActionResult Create(Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 18
0
        public ActionResult Create([Bind(Include = "id,Name,Rating,DownloadURL,ImgURL")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 19
0
        public ActionResult Create([Bind(Include = "Id,City,Street")] Address address)
        {
            if (ModelState.IsValid)
            {
                db.Addresses.Add(address);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(address));
        }
Exemplo n.º 20
0
        public ActionResult Create([Bind(Include = "Id,Name,Address,Age,MovieCard,Telephone,IsSubscribed")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
Exemplo n.º 21
0
        public ActionResult Create([Bind(Include = "Id,Title,Year,Director,LeadingMaleRole,LeadingMaleActorAge,LeadingFemaleRole,LeadingFemaleActorAge")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
Exemplo n.º 22
0
        public ActionResult Create([Bind(Include = "Id,Name,AddressId")] Studio studio)
        {
            if (ModelState.IsValid)
            {
                db.Studios.Add(studio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AddressId = new SelectList(db.Addresses, "Id", "City", studio.AddressId);
            return(View(studio));
        }
Exemplo n.º 23
0
        public IHttpActionResult Post(Movie movie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Movies.Add(movie);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = movie.Id }, movie));
        }
Exemplo n.º 24
0
        public ActionResult Create([Bind(Include = "SeriesId,SeriesName,NumberOfSeasons,Rating,AgeRating,GenreId")] Series series)
        {
            if (ModelState.IsValid)
            {
                db.Series.Add(series);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "GenreName", series.GenreId);
            return(View(series));
        }
Exemplo n.º 25
0
        public ActionResult Create([Bind(Include = "FilmId,FilmName,Duration,DirectorName,Rating,AgeRating,GenreId")] Film film)
        {
            if (ModelState.IsValid)
            {
                db.Films.Add(film);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "GenreName", film.GenreId);
            return(View(film));
        }
Exemplo n.º 26
0
        public IHttpActionResult PostDirector(Director director)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Directors.Add(director);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = director.Id }, director));
        }
Exemplo n.º 27
0
        public ActionResult Create([Bind(Include = "Id,Name,Age,StudioId,AddressId")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AddressId = new SelectList(db.Addresses, "Id", "City", person.AddressId);
            ViewBag.StudioId  = new SelectList(db.Studios, "Id", "Name", person.StudioId);
            return(View(person));
        }
Exemplo n.º 28
0
 public IActionResult AddMovie(Movie newMovie)
 {
     if (ModelState.IsValid)
     {
         _context.Movies.Add(newMovie);
         _context.SaveChanges();
         return(RedirectToAction("ViewMovies"));
     }
     else
     {
         return(View());
     }
 }
Exemplo n.º 29
0
        public ActionResult Create([Bind(Include = "Id,Date,Title,DirectorId,LeadingMaleRoleId,LeadingFemaleRoleId")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DirectorId          = new SelectList(db.People, "Id", "Name", movie.DirectorId);
            ViewBag.LeadingFemaleRoleId = new SelectList(db.People, "Id", "Name", movie.LeadingFemaleRoleId);
            ViewBag.LeadingMaleRoleId   = new SelectList(db.People, "Id", "Name", movie.LeadingMaleRoleId);
            return(View(movie));
        }
        public MovieDetails Post([FromBody] MovieDetails newMovie)
        {
            try
            {
                var addedMovie = this.context.Movies.Add(newMovie);
                context.SaveChanges();

                return(addedMovie.Entity);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 31
0
        public void SaveMovie(MoviesDbContext context, Movie movie)
        {
            if (movie.Id <= 0)
            {
                context.Entry(movie).State = EntityState.Added;
            }
            else
            {
                context.Entry(movie).State = EntityState.Modified;
            }

            context.SaveChanges();
        }
Exemplo n.º 32
0
 public void DeleteMovie(MoviesDbContext context, Movie movie)
 {
     context.Entry(movie).State = EntityState.Deleted;
     context.SaveChanges();
 }