예제 #1
0
        public string Busqueda(string tex)
        {
            List <movies> objetos = new List <movies>();

            objetos = tabla.getMovies();
            string texto = "Peliculas con Coincidencias: ";

            for (int x = 0; x < objetos.Count; x++)
            {
                movies nodo = objetos[x];
                if (nodo.title == tex)
                {
                    texto += nodo.title + " | ";
                }
                else if (nodo.description == tex)
                {
                    texto += nodo.title + " | ";
                }
                else if (nodo.years == tex)
                {
                    texto += nodo.title + " | ";
                }
                else if (nodo.director == tex)
                {
                    texto += nodo.title + " | ";
                }
            }
            return(texto);
        }
예제 #2
0
    public static ArrayList ShowMovies(string movieName1)
    {
        ArrayList listmovie = new ArrayList();
        string    query     = string.Format("SELECT * FROM TblMovies WHERE MovieName LIKE '{0}'", movieName1);


        try
        {
            connection.Open();
            cmmd.CommandText = query;
            SqlDataReader reader = cmmd.ExecuteReader();

            while (reader.Read())

            {
                string movieName   = reader.GetString(1);
                string amountMovie = reader.GetString(2);
                double totalPrice  = reader.GetDouble(3);
                string movieImage  = reader.GetString(4);

                movies movies1 = new movies(movieName, amountMovie, totalPrice, movieImage);
                listmovie.Add(movies1);
            }
        }
        finally
        {
            connection.Close();
        }

        return(listmovie);
    }
        /// <summary>
        /// Creates a new movie with default values
        /// </summary>
        /// <returns></returns>
        internal movies Create()
        {
            //Null Container for the time being
            movies movies = new movies();

            return movies;
        }
예제 #4
0
        public IHttpActionResult Putmovies(int id, movies movies)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != movies.id)
            {
                return(BadRequest());
            }

            db.Entry(movies).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!moviesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #5
0
        public void enterEditDataDAL(movies movie, List <actors> actors, List <actors> newActors, producers producer)
        {
            using (movieDAL dal = new movieDAL())
            {
                //dal.Database.ExecuteSqlCommand("insert into movieNProducer(movieId, producerId) values(" + movieId[0].movieId + "," + prodId[0].producerId + ")");

                var sqlMovie = @"Update movies set movieName = {0}, yor = {1}, plot = {2}, path = {3} where movieId = {4}";
                dal.Database.ExecuteSqlCommand(sqlMovie, movie.movieName, movie.yor, movie.plot, movie.path, movie.movieId);

                var sqlProducer = @"Update producers set producerName = {0}, producerSex = {1}, producerDOB = {2}, producerInfo = {3} where producerId = {4}";
                dal.Database.ExecuteSqlCommand(sqlProducer, producer.producerName, producer.producerSex, producer.producerDOB, producer.producerInfo, producer.producerId);


                foreach (actors actor in actors)
                {
                    var sqlActor = @"Update actors set actorName = {0}, actorSex = {1}, actorDOB = {2}, actorInfo = {3} where actorId = {4}";
                    dal.Database.ExecuteSqlCommand(sqlActor, actor.actorName, actor.actorSex, actor.actorDOB, actor.actorInfo, actor.actorId);
                }
                foreach (actors actor in newActors)
                {
                    dal.Database.ExecuteSqlCommand("insert into actors(actorName, actorSex, actorDOB, actorInfo) values('" + actor.actorName +
                                                   "','" + actor.actorSex + "','" + actor.actorDOB + "','" + actor.actorInfo + "')");

                    var actorId = dal.Actors.SqlQuery("Select * from actors where actorName=@p0", actor.actorName).ToList <actors>();
                    dal.Database.ExecuteSqlCommand("insert into movieNActor(movieId, actorId) values(" + movie.movieId + "," + actorId[0].actorId + ")");
                }
            }
        }
예제 #6
0
        public ActionResult Edit(movies a)
        {
            DB.Entry(a).State = System.Data.Entity.EntityState.Modified;
            DB.SaveChanges();

            return(RedirectToAction("GetAll"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            movies movies = db.movies.Find(id);

            db.movies.Remove(movies);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #8
0
 public ActionResult Index(movies newMovie)
 {
     movie.Add(new movies()
     {
         title = newMovie.title,
         janr  = newMovie.janr
     });
     return(View(movie));
 }
 public ActionResult Edit([Bind(Include = "movie_id,movie_title,director,year,genre_id")] movies movies)
 {
     if (ModelState.IsValid)
     {
         db.Entry(movies).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(movies));
 }
        public IHttpActionResult GetMovies(long id)
        {
            movies movies = db.movies.Find(id);

            if (movies == null)
            {
                return(NotFound());
            }

            return(Ok(movies));
        }
예제 #11
0
 public static Entity.Film ToFilmEntity(this movies element)
 {
     return(new Film
     {
         Nom = element.movie.title,
         DateSortie = element.movie.release_date,
         DureeEnMinute = element.movie.length,
         Synopsis = element.movie.synopsis,
         Casting = new List <Acteur>()
     });
 }
        public ActionResult Create([Bind(Include = "movie_id,movie_title,director,year,genre_id")] movies movies)
        {
            if (ModelState.IsValid)
            {
                db.fillmoviesTable(movies.director, movies.genre_id, movies.movie_id, movies.movie_title, movies.year);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movies));
        }
예제 #13
0
        public model.Movie findOrFail(String name)
        {
            movies movie = this.Context.movies.Where(m => m.url == name).FirstOrDefault();

            if (movie == null)
            {
                throw new NotFoundModelException();
            }

            return(Mapper.Map <movies, model.Movie>(movie));
        }
예제 #14
0
        public IHttpActionResult Postmovies(movies movies)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.movies.Add(movies);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = movies.id }, movies));
        }
예제 #15
0
        public ActionResult Update(HttpPostedFileBase file, movies movie, producers producer, List <string> actorName,
                                   List <int> actorId, List <string> actorSex, List <DateTime> actorDOB,
                                   List <string> actorInfo, string BtnSubmit)
        {
            List <actors> actorList    = new List <actors>();
            List <actors> newActorList = new List <actors>();

            int tempCount = actorId.Count;

            for (int i = 0; i < actorName.Count; i++)
            {
                if (actorName[i] != null && actorName[i] != String.Empty)
                {
                    actors act = new actors();
                    act.actorName = actorName[i];
                    act.actorSex  = actorSex[i];
                    act.actorDOB  = actorDOB[i];
                    act.actorInfo = actorInfo[i];

                    if (i < tempCount)
                    {
                        actorList.Add(act);
                    }
                    else
                    {
                        newActorList.Add(act);
                    }
                }
            }

            if (file.ContentLength > 0)
            {
                string _FileName = Path.GetFileName(file.FileName);
                string _path     = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName);
                file.SaveAs(_path);
                movie.path = "/UploadedFiles/" + _FileName;

                switch (BtnSubmit)
                {
                case "Save Employee":
                    movieBLC blc = new movieBLC();
                    blc.enterEditData(movie, actorList, newActorList, producer);
                    return(RedirectToAction("Read", "movieList"));

                case "Cancel":
                    return(RedirectToAction("Index"));
                }
                return(new EmptyResult());
            }
            ViewBag.Message = "File Upload Failed!!";
            return(RedirectToAction("Read", "movieList"));
        }
        public IHttpActionResult GetImport(string movieTag)
        {
            string apikey  = ConfigurationManager.AppSettings["apikey"];
            string baseUrl = "https://api.themoviedb.org/3/find/%IMDBID%?external_source=imdb_id&api_key=%APIKEY%";
            string url     = baseUrl.Replace("%IMDBID%", movieTag).Replace("%APIKEY%", apikey);
            string json    = "";

            using (WebClient fetcher = new WebClient())
            {
                json = fetcher.DownloadString(url);
            }

            if (json == "")
            {
                return(Content(HttpStatusCode.ServiceUnavailable, "Api not responding"));
            }

            dynamic data = JsonConvert.DeserializeObject(json);

            if (data.movie_results == null || data.movie_results.Count < 1)
            {
                return(Content(HttpStatusCode.NotFound, "Movie tag not fund"));
            }
            dynamic movieResult = data.movie_results[0];

            //if movie is alredy in data base do not make a duplicate
            IQueryable <movies> querry = db.movies.Where(movieFind => movieFind.imdb_tag == movieTag);
            int    existingMovie       = querry.Count();
            movies movie = null;

            if (existingMovie < 1)
            {
                //Add new movie
                movie          = new movies();
                movie.imdb_tag = movieTag;
                db.movies.Add(movie);
            }
            else
            {
                movie = querry.First <movies>();
            }

            movie.title       = movieResult.title;
            movie.description = movieResult.overview;
            movie.language    = movieResult.original_language;

            movie.premiere = DateTime.ParseExact("" + movieResult.release_date, "yyyy-MM-dd", CultureInfo.InvariantCulture);

            movie.image_url = "https://image.tmdb.org/t/p/w185_and_h278_bestv2/" + movieResult.poster_path;
            db.SaveChanges();
            return(Ok(movie));
        }
        /// <summary>
        /// Saves a new movie.
        /// </summary>
        /// <param name="movie"></param>
        /// <returns></returns>
        internal movies Save(movies movie)
        {
            // Read in the existing movies
            var movies = this.fetchMovies();

            // Assign a new Id
            var maxId = movies.Max(p => p.id);
            movie.id = maxId + 1;
            movies.Add(movie);

            WriteToFile(movies);
            return movie;
        }
예제 #18
0
        public IHttpActionResult Deletemovies(int id)
        {
            movies movies = db.movies.Find(id);

            if (movies == null)
            {
                return(NotFound());
            }

            db.movies.Remove(movies);
            db.SaveChanges();

            return(Ok(movies));
        }
        // GET: movies/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            movies movies = db.movies.Find(id);

            if (movies == null)
            {
                return(HttpNotFound());
            }
            return(View(movies));
        }
예제 #20
0
        public ActionResult Update(int movieId)
        {
            movieBLC  blc        = new movieBLC();
            DataSet   ds         = blc.editData(movieId);
            DataTable movieDT    = ds.Tables[0];
            DataTable actorsDT   = ds.Tables[1];
            DataTable producerDT = ds.Tables[2];

            editData edata = new editData();

            foreach (DataRow row in movieDT.Rows)
            {
                movies movie = new movies();
                movie.movieId   = Convert.ToInt32(row["movieId"]);
                movie.movieName = row["movieName"].ToString();
                movie.plot      = row["plot"].ToString();
                movie.path      = row["path"].ToString();
                movie.yor       = Convert.ToInt32(row["yor"]);
                edata.movie     = movie;
            }

            List <actors> act = new List <actors>();

            foreach (DataRow row in actorsDT.Rows)
            {
                actors actor = new actors();
                actor.actorDOB  = Convert.ToDateTime(row["actorDOB"]);
                actor.actorId   = Convert.ToInt32(row["actorId"]);
                actor.actorInfo = row["actorInfo"].ToString();
                actor.actorName = row["actorName"].ToString();
                actor.actorSex  = row["actorSex"].ToString();
                act.Add(actor);
            }
            edata.actors = act;

            foreach (DataRow row in producerDT.Rows)
            {
                producers producer = new producers();
                producer.producerDOB  = Convert.ToDateTime(row["producerDOB"]);
                producer.producerId   = Convert.ToInt32(row["producerId"]);
                producer.producerInfo = row["producerInfo"].ToString();
                producer.producerName = row["producerName"].ToString();
                producer.producerSex  = row["producerSex"].ToString();
                edata.producer        = producer;
            }

            return(View("Update", edata));
        }
예제 #21
0
        public ActionResult Create(HttpPostedFileBase file, movies movie, producers producer,
                                   List <string> actorName, List <string> actorSex, List <DateTime> actorDOB,
                                   List <string> actorInfo, string BtnSubmit, List <string> actorsDB, string producersDB)
        {
            try
            {
                List <actors> actorList = new List <actors>();
                for (int i = 0; i < actorName.Count; i++)
                {
                    if (actorName[i] != null && actorName[i] != String.Empty)
                    {
                        actors act = new actors();
                        act.actorName = actorName[i];
                        act.actorSex  = actorSex[i];
                        act.actorDOB  = actorDOB[i];
                        act.actorInfo = actorInfo[i];
                        actorList.Add(act);
                    }
                }

                if (file.ContentLength > 0)
                {
                    string _FileName = Path.GetFileName(file.FileName);
                    string _path     = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName);
                    file.SaveAs(_path);
                    movie.path = "/UploadedFiles/" + _FileName;
                    ////dump into database
                    switch (BtnSubmit)
                    {
                    case "Save Details":
                        movieBLC blc = new movieBLC();
                        blc.enterDataBLC(movie, producer, actorList, actorsDB, producersDB);
                        return(RedirectToAction("Read", "movieList"));

                    case "Cancel":
                        return(RedirectToAction("Create"));
                    }
                    return(new EmptyResult());
                }
                ViewBag.Message = "File Upload failed!!";
                return(RedirectToAction("Create", "movieList"));
            }
            catch
            {
                ViewBag.Message = "File upload failed!!";
                return(View());
            }
        }
        /// <summary>
        /// Updates an existing movie
        /// </summary>
        /// <param name="id"></param>
        /// <param name="movie"></param>
        /// <returns></returns>
        internal movies Save(int id, movies movie)
        {
            // Read in the existing products
            var movies = this.fetchMovies();

            // Locate and replace the item
            var itemIndex = movies.FindIndex(p => p.id == movie.id);
            if (itemIndex > 0)
            {
                movies[itemIndex] = movie;
            }
            else
            {
                return null;
            }

            WriteToFile(movies);
            return movie;
        }
예제 #23
0
    public static void AddProduct(movies movie)
    {
        string query = string.Format(
            @"INSERT INTO TblMovies VALUES ('{0}', '{1}', @prices, '{2}')",
            movie.MovieName, movie.AmountMovie, movie.TotalPrice, movie.MovieImage);

        cmmd.CommandText = query;
        cmmd.Parameters.Add(new SqlParameter("@prices", movie.TotalPrice));
        try
        {
            connection.Open();
            cmmd.ExecuteNonQuery();
        }
        finally
        {
            connection.Close();
            cmmd.Parameters.Clear();
        }
    }
예제 #24
0
        public ActionResult Add()
        {
            string title    = Request["title"];
            int    duration = Convert.ToInt32(Request["duration"]);
            string genre    = Request["genre"];
            int    year     = Convert.ToInt32(Request["year"]);
            float  rating   = Convert.ToInt32(Request["rating"]);
            movies m        = new movies();

            m.Title        = title;
            m.Duration     = duration;
            m.Genre        = genre;
            m.Release_Year = year;
            m.Rating       = rating;

            dc.movies.InsertOnSubmit(m);
            dc.SubmitChanges();

            return(RedirectToAction("AddMovie"));
        }
예제 #25
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string movieName   = movieNametxt.Text;
            string amountMovie = amountMovietxt.Text;
            double totalPrice  = Convert.ToDouble(totalPricetxt.Text);
            totalPrice = totalPrice / 100;
            string movieImage = "../ProductImage/" + ddlImage.SelectedValue;


            movies movieList = new movies(movieName, amountMovie, totalPrice, movieImage);
            mothercode.AddProduct(movieList);
            lblResult.Text = "Upload succesful!";
            ClearTextFields();
        }
        catch (Exception)
        {
            lblResult.Text = "Upload failed!";
        }
    }
예제 #26
0
    private static void start_get()
    {
        HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(string.Format("http://www.omdbapi.com/?apikey=84739f5e&t=lost"));

        WebReq.Method = "GET";

        HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();

        Console.WriteLine(WebResp.StatusCode);
        Console.WriteLine(WebResp.Server);

        string jsonString;

        using (Stream stream = WebResp.GetResponseStream())   //modified from your code since the using statement disposes the stream automatically when done
        {
            StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8);
            jsonString = reader.ReadToEnd();
        }

        movies item = JsonConvert.DeserializeObject <movies>(jsonString);

        Console.WriteLine(item.imdbID);     //returns 921, the number of items on that page
    }
예제 #27
0
 public ActionResult create([Bind(Include = "name,year,rate")] movies a)
 {
     DB.movies.Add(a);
     DB.SaveChanges();
     return(RedirectToAction("GetAll"));
 }
예제 #28
0
        public bool PUT(string id, string title, string description, string years, string director)
        {
            movies nodo = new movies(id, title, description, years, director);

            return(tabla.putMovies(nodo));
        }
예제 #29
0
        public movies GET(string id)
        {
            movies nodo = tabla.getMovies(id);

            return(nodo);
        }
예제 #30
0
 public Forestillinger(movies movie, sal sale, Tidspunkt tid)
 {
     _movie     = movie;
     _sal       = sale;
     _tidspunkt = tid;
 }
예제 #31
0
 public void Post([FromBody] movies value)
 {
     _context.movies.Add(value);
     _context.SaveChanges();
 }