Ejemplo n.º 1
0
        private void DeleteActor()
        {
            int actorId = Convert.ToInt32(txbActorId.Text);

            actor actor = db.actors.FirstOrDefault(x => x.act_id == actorId);

            if (actor == null)
            {
                MessageBox.Show("Actor không tồn tại, xoá không thành công");
            }
            else
            {
                try
                {
                    db.actors.Remove(actor);
                    db.SaveChanges();

                    MessageBox.Show("Xoá thành công");

                    ReloadDataGird();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Xoá không thành công");
                }
            }
        }
Ejemplo n.º 2
0
        public override ICollection <actor> getActors(HtmlNode victimDetailContent)
        {
            var dd = victimDetailContent.SelectNodes("//div[@class='dinfo'] //dd");

            string[]            actors = dd[1].InnerText.Trim().Split(',');
            ICollection <actor> acts   = new HashSet <actor>();

            foreach (var actor in actors)
            {
                try {
                    string actorName = actor.Trim();
                    if (actorName == "")
                    {
                        continue;
                    }
                    var alias     = UnicodeUtil.convertToAlias(actorName);
                    var newEntity = new actor()
                    {
                        name = actorName, alias = alias
                    };
                    if (actorExisted(actorName))
                    {
                        newEntity = findActorByName(actorName);
                        setModified(newEntity);
                    }
                    acts.Add(newEntity);
                }
                catch
                {
                    continue;
                }
            }
            return(acts);
        }
Ejemplo n.º 3
0
        public void AddActor()
        {
            if (txbActorFirstName.Text == "" ||
                txbActorLastName.Text == "" ||
                cbbActorGender.selectedValue == "")
            {
                MessageBox.Show("Thông tin chưa đủ");
            }

            try
            {
                actor actor = new actor();
                actor.act_fname  = txbActorFirstName.Text;
                actor.act_lname  = txbActorLastName.Text;
                actor.act_gender = cbbActorGender.selectedValue;
                actor.act_image  = txbActorImage.Text;
                db.actors.Add(actor);
                db.SaveChanges();

                MessageBox.Show("Thêm actor thành công");

                ReloadDataGird();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thêm actor thất bại");
            }
        }
Ejemplo n.º 4
0
        public ActionResult CommitShooter(actor a)
        {
            string query = "Update shooters.shooter set Middle = '" + a.Middle + "', birth = '" + a.birth + "', Death = '" + a.death + "' where First = '" + a.First + "' AND Last = '" + a.Last + "'";

            QueryUtils.query(query);
            return(RedirectToAction("EditShooter", new { first = a.First, last = a.Last }));
        }
Ejemplo n.º 5
0
        public void TestarIncluirFilmeAtor()
        {
            var filme = new film()
            {
                title       = "A VOLTA DOS QUE N�O FORAM",
                language_id = 1
            };

            var ator = new actor()
            {
                first_name  = "FABIO",
                last_name   = "QUIRINO",
                last_update = DateTime.Now
            };

            var film_actor = new film_actor()
            {
                actor       = ator,
                film        = filme,
                last_update = DateTime.Now
            };

            filme.films_actors = new List <film_actor>()
            {
                film_actor
            };

            new ServicoFilm().Incluir(filme);
            Assert.IsTrue(true);
        }
Ejemplo n.º 6
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dgvActors.SelectedRows.Count > 0)
     {
         try
         {
             using (MovieDB context = new MovieDB())
             {
                 DataGridViewRow row   = dgvActors.SelectedRows[0];
                 actor           actor = (actor)row.Tag;
                 if (MessageBox.Show("Are you sure you want to delete actor: " + actor.member_of_cast_and_crew.first_name + " " + actor.member_of_cast_and_crew.last_name + "?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     context.actors.Attach(actor);
                     actor.member_of_cast_and_crew.active = 0;
                     context.SaveChanges();
                     RefreshTableAndFilters();
                     DirectorsUcl.Instance.RefreshTableAndFilters();
                     MoviesUcl.Instance.RefreshTableAndFilters();
                     MessageBox.Show("Actor successfully deleted.", "Success", MessageBoxButtons.OK);
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.StackTrace);
         }
     }
     else
     {
         MessageBox.Show("You haven't chosen an actor.", "Warning", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 7
0
        public void Delete(actor ator)
        {
            using (var db = new SakilaContext())
            //Como não há concorrência nas modificações, não é necessário criar um contexto transacional.
            //using (var transacao = db.Database.BeginTransaction())
            {
                try
                {
                    db.films_actors.RemoveRange(ator.films_actors);
                    db.actors.Remove(ator);

                    db.SaveChanges();
                    //transacao.Commit();
                }
                catch
                {
                    //transacao.Rollback();
                    //tratar exceção e gravar no log além de fechar a transação
                    throw;
                }

/*                 finally
 *              {
 *                  transacao.Dispose();
 *              };
 */         }
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Putactor([FromRoute] int id, [FromBody] actor actor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(actor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!actorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 9
0
 //Обновление указанного объекта ListView
 public void UpdateItemInTable(ListViewItem item, actor a)
 {
     item.SubItems[0].Text = a.name;
     item.SubItems[1].Text = a.birthday.HasValue ? a.birthday.Value.ToShortDateString() : null;
     item.SubItems[2].Text = a.country;
     item.SubItems[3].Text = a.description;
 }
Ejemplo n.º 10
0
        public override ICollection <actor> getActors(HtmlNode victimDetailContent)
        {
            var dd = victimDetailContent.SelectNodes("//ul[@class='meta-data'] //li");

            string[]            actors = convertNodesToArray(dd[dd.Count - 9].SelectNodes("./a"));
            ICollection <actor> acts   = new HashSet <actor>();

            foreach (var actor in actors)
            {
                try {
                    string actorName = actor.Trim();
                    if (actorName == "")
                    {
                        continue;
                    }
                    var alias     = UnicodeUtil.convertToAlias(actorName);
                    var newEntity = new actor()
                    {
                        name = actorName, alias = alias
                    };
                    if (actorExisted(actorName))
                    {
                        newEntity = findActorByName(actorName);
                        setModified(newEntity);
                    }
                    acts.Add(newEntity);
                }
                catch
                {
                    continue;
                }
            }
            return(acts);
        }
Ejemplo n.º 11
0
 public void Update(actor ator)
 {
     using (var db = new SakilaContext())
     {
         db.actors.Update(ator);
         db.SaveChanges();
     }
 }
Ejemplo n.º 12
0
        private actor GetActorFilmById(int id)
        {
            VerifyNullIntParameter(id);
            var   servicoAtor = new sakila.repositorio.servico.ServicoActor();
            actor ator        = servicoAtor.GetActorFilmById(id);

            return(ator);
        }
Ejemplo n.º 13
0
        public ViewResult ConfirmDeleteActor(int id)
        {
            var servicoAtor = new sakila.repositorio.servico.ServicoActor();

            actor ator = servicoAtor.GetActorFilmById(id);

            return(View("Views/Actor/ConfirmDeleteActor.cshtml", ator));
        }
Ejemplo n.º 14
0
 public void Insert(actor ator)
 {
     using (var db = new SakilaContext())
     {
         db.actors.Add(ator);
         db.SaveChanges();
     }
 }
Ejemplo n.º 15
0
        public ActionResult DeleteConfirmed(int id)
        {
            actor actor = db.actors.Find(id);

            db.actors.Remove(actor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 16
0
        public void DeleteActor(int id)
        {
            actor actor = db.actors.Find(id);

            db.actors.Attach(actor);
            db.actors.Remove(actor);
            db.SaveChanges();
        }
Ejemplo n.º 17
0
 public void AddActor(actor actor)
 {
     if (actor == null)
     {
         return;
     }
     db.actors.Add(actor);
     db.SaveChanges();
 }
Ejemplo n.º 18
0
        //Поиск всех фильмов данного актёра
        public List <film> GetFilmsForActors(DataContext ctx, actor a)
        {
            List <film> rez;

            rez = (from contract in ctx.films_and_actors
                   where contract.actor_id == a.id
                   select contract.film).ToList();
            return(rez);
        }
Ejemplo n.º 19
0
        public static actor Factory(TextBox txtId, TextBox txtNombre, TextBox txtApellido, TextBox txtEdad)
        {
            var nuevoActor = new actor();

            nuevoActor.actor_id   = Convert.ToInt32(txtId.Text);
            nuevoActor.first_name = txtNombre.Text;
            nuevoActor.last_name  = txtApellido.Text;

            return(nuevoActor);
        }
Ejemplo n.º 20
0
 public ActionResult Edit([Bind(Include = "Actor_Id,Actor_name,Sex,Date_Of_Birth,Bio")] actor actor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(actor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(actor));
 }
Ejemplo n.º 21
0
        public ActionResult ViewShooterGuns(string first, string last)
        {
            actor _actor             = TableUtils.queryToObject <actor>("SELECT * FROM shooters.shooter where first= '" + first + "' AND last = '" + last + "'");
            List <gunPurchase> _list = TableUtils.queryToTable <gunPurchase>("SELECT * FROM shooters.gunPurchase where first= '" + first + "' AND last = '" + last + "'");

            ShooterGP model = new ShooterGP();

            model._actor = _actor;
            model._guns  = _list;
            return(View(model));
        }
Ejemplo n.º 22
0
        public ActionResult Create([Bind(Include = "Actor_Id,Actor_name,Sex,Date_Of_Birth,Bio")] actor actor)
        {
            if (ModelState.IsValid)
            {
                db.actors.Add(actor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(actor));
        }
Ejemplo n.º 23
0
 public ActorForm(actor actor)
 {
     this.actor = actor;
     InitializeComponent();
     if (actor.id == 0)
     {
         return;
     }
     textBox_ActorFname.Text = actor.fname;
     textBox_ActorLname.Text = actor.lname;
 }
Ejemplo n.º 24
0
 //Добавление актёра в БД. Возвращает id добавленного актёра, или -1 при ошибке
 public int AddActorToDB(actor newActor)
 {
     if (AddObjectToDB("actor", newActor) == false)
     {
         return(-1);
     }
     else
     {
         return(newActor.id); //id обновилось при сохранении изменений в БД
     }
 }
Ejemplo n.º 25
0
 public static ActorDTO Create(actor actor)
 {
     return(new ActorDTO
     {
         Id = actor.actor_id,
         FirstName = actor.first_name,
         LastName = actor.last_name,
         Birthday = actor.birthday?.DateTime,
         Movies = actor.movies?.Select(x => MovieDTO.Create(x)).ToList()
     });
 }
Ejemplo n.º 26
0
        public actor ObterPorSobrenome(string sobrenome)
        {
            actor ator = null;

            using (var db = new SakilaContext())
            {
                ator = db.actors.FirstOrDefault(x => x.last_name.Contains(sobrenome));
            }

            return(ator);
        }
Ejemplo n.º 27
0
        public actor GetById(int?primarykey)
        {
            actor ator = null;

            using (var db = new SakilaContext())
            {
                ator = ObterPorId(db, primarykey.Value);
            }

            return(ator);
        }
Ejemplo n.º 28
0
        public async Task <IActionResult> Postactor([FromBody] actor actor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.actors.Add(actor);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getactor", new { id = actor.id }, actor));
        }
Ejemplo n.º 29
0
        private void btn_AddActor_Click(object sender, EventArgs e)
        {
            actor     actor = new actor();
            ActorForm form  = new ActorForm(actor);

            var result = form.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            _model.AddActor(form.getActor());
            Refresh();
        }
Ejemplo n.º 30
0
        public ViewResult InsertActor(actor ator)
        {
            var servicoAtor = new sakila.repositorio.servico.ServicoActor();

            ator.last_update = DateTime.Now;

            servicoAtor.Insert(ator);

            var atores = servicoAtor.Listar();

            TempData["mensagem"] = "Ator Criado com Sucesso!";

            return(View("Views/Actor/Index.cshtml", atores));
        }