Example #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"));
        }
Example #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());
            }
        }
Example #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));
        }
Example #4
0
        /// <summary>
        /// Maps (converts) the provided <see cref="producers" /> instance to the <see cref="IEnumerable{IProducer}" /> instance
        /// </summary>
        /// <param name="message">A <see cref="producers" /> instance to be mapped (converted)</param>
        /// <returns>A <see cref="IEnumerable{IProducer}" /> instance constructed from information in the provided <see cref="producers" /></returns>
        private IEnumerable <IProducer> MapProducers(producers message)
        {
            Guard.Argument(message, nameof(message)).NotNull();
            Guard.Argument(message.producer.Length, nameof(message.producer.Length)).Positive();

            return(message.producer.Select(producer => new Producer((int)producer.id,
                                                                    producer.name,
                                                                    producer.description,
                                                                    _config.Environment != SdkEnvironment.Custom
                                                                        ? producer.api_url
                                                                        : ReplaceProducerApiUrl(producer.api_url),
                                                                    producer.active,
                                                                    _config.InactivitySeconds,
                                                                    _config.MaxRecoveryTime,
                                                                    producer.scope,
                                                                    producer.stateful_recovery_window_in_minutes)).Cast <IProducer>().ToList());
        }
        /// <summary>
        /// Maps (converts) the provided <see cref="producers" /> instance to the <see cref="IEnumerable{IProducer}" /> instance
        /// </summary>
        /// <param name="message">A <see cref="producers" /> instance to be mapped (converted)</param>
        /// <returns>A <see cref="IEnumerable{IProducer}" /> instance constructed from information in the provided <see cref="producers" /></returns>
        private IEnumerable <IProducer> MapProducers(producers message)
        {
            Contract.Requires(message != null);
            Contract.Requires(message.producer.Length > 0);

            return(message.producer.Select(producer => new Producer(
                                               (int)producer.id,
                                               producer.name,
                                               producer.description,
                                               _config.Environment != SdkEnvironment.Custom
                                                                        ? producer.api_url
                                                                        : ReplaceProducerApiUrl(producer.api_url),
                                               producer.active,
                                               _config.InactivitySeconds,
                                               producer.stateful_recovery_window_in_minutes,
                                               producer.scope)).Cast <IProducer>().ToList());
        }
 /// <summary>
 ///     Constructs and returns a new instance of the <see cref="ISingleTypeMapper{T}" /> instance used to map
 ///     <see cref="producers" /> instances
 ///     to <see cref="EntityList{ProducerDTO}" /> instances
 /// </summary>
 /// <param name="data">A <see cref="producers" /> instance containing tournaments data</param>
 /// <returns>
 ///     a new instance of the <see cref="ISingleTypeMapper{T}" /> instance used to map <see cref="producers" /> instances
 ///     to <see cref="EntityList{ProducerDTO}" /> instances
 /// </returns>
 internal static ISingleTypeMapper <EntityList <ProducerDTO> > Create(producers data)
 {
     return(new ProducersMapper(data));
 }
        /// <summary>
        ///     Initializes a new instance of the <see cref="ProducersMapper" /> class
        /// </summary>
        /// <param name="data">The <see cref="producers" /> instance containing data about available producers.</param>
        protected ProducersMapper(producers data)
        {
            Contract.Requires(data != null);

            _data = data;
        }
Example #8
0
 /// <summary>
 /// Creates and returns a <see cref="ISingleTypeMapper{T}" /> instance used to map <see cref="producers"/> instances to
 /// <see cref="EntityList{ProducerDTO}"/> instances
 /// </summary>
 /// <param name="data">A <see cref="producers" /> instance which the created <see cref="ISingleTypeMapper{T}" /> will map</param>
 /// <returns>The constructed <see cref="ISingleTypeMapper{T}" /> instance</returns>
 public ISingleTypeMapper <EntityList <ProducerDTO> > CreateMapper(producers data)
 {
     return(ProducersMapper.Create(data));
 }
Example #9
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 + ")");
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProducersMapper"/> class
        /// </summary>
        /// <param name="data">The <see cref="producers"/> instance containing data about available producers.</param>
        protected ProducersMapper(producers data)
        {
            Guard.Argument(data, nameof(data)).NotNull();

            _data = data;
        }