Esempio n. 1
0
        public IResult CreateVideoClub(ITransaction tx, VideoClub vc)
        {
            String query = $"create (vc:VideoClub{{name:'{vc.Name}', city:'{vc.City}', adress:'{vc.Adress}', " +
                           $"email:'{vc.Email}', phoneNumber:'{vc.PhoneNumber}'}})";

            return(tx.Run(query));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "PeliculaID,Name,Director,ReleaseDate,Price")] Pelicula pelicula)
        {
            try
            {
                List <VideoClub> listaVC = new List <VideoClub>();
                VideoClub        vc      = null;
                foreach (VideoClub vd in db.VideoClubs)
                {
                    listaVC.Add(vd);
                }

                if (listaVC != null)
                {
                    string[] strCadena = Request.Form["name"].Split(',');
                    var      strnombre = strCadena[1];
                    vc = listaVC.Where(s => s.Name.Equals(strnombre)).FirstOrDefault();
                }

                if (vc != null)
                {
                    pelicula.VideoClub = vc;
                }
            }
            catch { }

            if (ModelState.IsValid)
            {
                db.Peliculas.Add(pelicula);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pelicula));
        }
Esempio n. 3
0
        public ActionResult Registro([Bind(Include = "SocioID,Name,Password,Age,VideoClub")] Socio socio)
        {
            try
            {
                List <VideoClub> listaVC = new List <VideoClub>();
                VideoClub        vc      = null;
                foreach (VideoClub vd in db.VideoClubs)
                {
                    listaVC.Add(vd);
                }

                if (listaVC != null)
                {
                    string[] strCadena = Request.Form["name"].Split(',');
                    var      strnombre = strCadena[1];
                    vc = listaVC.Where(s => s.Name.Equals(strnombre)).FirstOrDefault();
                }

                if (vc != null)
                {
                    socio.VideoClub = vc;
                }
            }
            catch { }

            if (ModelState.IsValid)
            {
                db.Socios.Add(socio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(socio));
        }
Esempio n. 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            VideoClub videoClub = db.VideoClubs.Find(id);

            db.VideoClubs.Remove(videoClub);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "VideoClubID,Name,City,Address,Zip")] VideoClub videoClub)
 {
     if (ModelState.IsValid)
     {
         db.Entry(videoClub).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(videoClub));
 }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "VideoClubID,Name,City,Address,Zip")] VideoClub videoClub)
        {
            if (ModelState.IsValid)
            {
                db.VideoClubs.Add(videoClub);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(videoClub));
        }
Esempio n. 7
0
        // GET: VideoClubs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VideoClub videoClub = db.VideoClubs.Find(id);

            if (videoClub == null)
            {
                return(HttpNotFound());
            }
            return(View(videoClub));
        }
Esempio n. 8
0
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            VideoClub vc = null;

            using (var session = DataProvider.Driver.Session())
            {
                vc = session.ReadTransaction(tx => DataProvider.Instance.GetVideoClub(tx, textBoxRemoveName.Text));
                if (vc != null)
                {
                    session.WriteTransaction(tx => DataProvider.Instance.DeleteVideoClub(tx, textBoxRemoveName.Text));
                    MessageBox.Show("You have successfully deleted video club.");
                }
                else
                {
                    MessageBox.Show("Video club doesn't exist.");
                }
            }
        }
Esempio n. 9
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            VideoClub vc = null;

            using (var session = DataProvider.Driver.Session())
            {
                vc = session.ReadTransaction(tx => DataProvider.Instance.GetVideoClub(tx, textBoxName.Text));
                if (vc == null)
                {
                    vc = new VideoClub(textBoxName.Text, textBoxCity.Text, textBoxAdress.Text, textBoxEmail.Text, textBoxPhone.Text);
                    session.WriteTransaction(tx => DataProvider.Instance.CreateVideoClub(tx, vc));
                    MessageBox.Show("You have successfully added a new video club.");
                }
                else
                {
                    MessageBox.Show("Video club already exists.");
                }
            }
        }
Esempio n. 10
0
        private void buttonAddMovieToVc_Click(object sender, EventArgs e)
        {
            VideoClub vc = null;
            Movie     m  = null;

            using (var session = DataProvider.Driver.Session())
            {
                vc = session.ReadTransaction(tx => DataProvider.Instance.GetVideoClub(tx, textBoxVcName.Text));
                session.ReadTransaction(tx => m = DataProvider.Instance.GetMovie(tx, textBoxMovieTitle.Text));
                if (m != null && vc != null)
                {
                    session.WriteTransaction(tx => DataProvider.Instance.AddMovieToVideoClub(tx, textBoxVcName.Text, textBoxMovieTitle.Text));
                    MessageBox.Show("You have successfully added movie to the video club.");
                }
                else
                {
                    MessageBox.Show("Video club or movie doesn't exist.");
                }
            }
        }
Esempio n. 11
0
        private void buttonRent_Click(object sender, EventArgs e)
        {
            VideoClub vc = null;
            Movie     m  = null;

            using (var session = DataProvider.Driver.Session())
            {
                vc = session.ReadTransaction(tx => DataProvider.Instance.GetVideoClub(tx, textBoxVideoClub.Text));
                m  = session.ReadTransaction(tx => DataProvider.Instance.GetMovie(tx, textBoxMovie.Text));
                if (vc != null && m != null)
                {
                    session.WriteTransaction(tx => DataProvider.Instance.RentMovie(tx, textBoxVideoClub.Text, textBoxMovie.Text));
                    session.WriteTransaction(tx => DataProvider.Instance.RentRelation(tx, DataProvider.Instance.User, textBoxMovie.Text));
                    MessageBox.Show("You have successfully rented movie " + textBoxMovie.Text + ".");
                }
                else
                {
                    MessageBox.Show("Video club or movie doesn't exist.");
                }
            }
        }