Ejemplo n.º 1
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"));
        }
Ejemplo n.º 2
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());
            }
        }
Ejemplo n.º 3
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));
        }