Esempio n. 1
0
        public void Delete_Returns_True_If_Deleted_Existing()
        {
            Director d = new Director();

            d.FirstName = "Test Delete";
            d.LastName  = "Test";
            int id = manager.Create(d);

            bool actual = manager.Delete(id);

            Assert.IsTrue(actual);
        }
Esempio n. 2
0
 private void DeleteDirector()
 {
     director.Id          = Int32.Parse(textBox1.Text);
     director.FirstName   = textBox2.Text;
     director.LastName    = textBox3.Text;
     director.Nationality = textBox4.Text;
     director.Birth       = DateTime.Parse(dateTimePicker1.Text.ToString());
     directorManager.Delete(director);
 }
Esempio n. 3
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            DirectorManager manager = new DirectorManager();
            int             id      = Convert.ToInt32(DirectorsDropdownList.SelectedValue);

            manager.Delete(id);
            DoDataBind();
            FirstNameTextBox.Text = string.Empty;
            LastNameTextBox.Text  = string.Empty;
            manager.Dispose();
        }
Esempio n. 4
0
 public ActionResult Delete(int id, Director director)
 {
     try
     {
         // TODO: Add delete logic here
         DirectorManager.Delete(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 5
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         DirectorManager.Delete(id);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ViewBag.message = ex.Message;
         return(View());
     }
 }
 public ActionResult Delete(Director director)
 {
     using (manager = new DirectorManager())
     {
         manager.Delete(director.Id);
     }
     if (director == null)
     {
         return(HttpNotFound());
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Director director = directorManager.Find(I => I.Id == id);
            Movie    movie    = CurrentSession.Get <Movie>("selectedMovie");

            if (movie != null)
            {
                movie.Directors.Remove(director);
                directorManager.Save();
                return(RedirectToAction("Index"));
            }

            directorManager.Delete(director);
            if (director.ImagePath != "defaultPhoto.png")
            {
                System.IO.File.Delete(Server.MapPath($"~/img/DirectorPhotos/{director.ImagePath}"));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                // Get the one the user has selected

                director = directors[ddlDirectors.SelectedIndex];


                // Add to the database
                DirectorManager.Delete(director.Id);

                // Remove it from the list
                directors.Remove(director);

                Rebind();
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.Message);
            }
        }
Esempio n. 9
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                //get the selected  object that i want to use
                item = items[ddlExisting.SelectedIndex];

                //delete it from the database
                int results = DirectorManager.Delete(item.Id);
                //remove it from degreeTypes
                items.Remove(item);

                //rebind
                Rebind();

                Response.Write("Deleted " + results + " rows...");
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }