public override Midia InsertMidia(MidiaType midia_type, string nome_album)
        {
            Midia new_album = new BluRay(nome_album);

            string sql = "INSERT INTO BLURAY (nome_album) " +
                         "VALUES (@Nome_Album)";
            SqlCommand cmd = new SqlCommand(sql, SqlDbConnection.getConnection());

            cmd.Parameters.AddWithValue("@Nome_Album", nome_album);
            cmd.CommandType = CommandType.Text;
            SqlDbConnection.cn.Open();

            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    Console.WriteLine("Registro incluido com sucesso!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erro: " + ex.ToString());
            }
            finally
            {
                SqlDbConnection.cn.Close();
            }

            return(new_album);
        }
示例#2
0
 public ActionResult Edit(BluRay blueRay)
 {
     if (ModelState.IsValid)
     {
         using (MyDbContext db = new MyDbContext())
         {
             db.Entry(blueRay).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View(blueRay));
 }
示例#3
0
 public ActionResult Create(BluRay bluRay)
 {
     if (ModelState.IsValid)
     {
         using (MyDbContext db = new MyDbContext())
         {
             db.BluRays.Add(bluRay);
             db.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.Message = bluRay.Title + " successfully created.";
     }
     return(View());
 }
示例#4
0
 //Details
 public ActionResult Details(int id)
 {
     using (MyDbContext db = new MyDbContext())
     {
         BluRay blueRay = db.BluRays.FirstOrDefault(u => u.Id == id);
         if (blueRay != null)
         {
             return(View(blueRay));
         }
         else
         {
             return(HttpNotFound());
         }
     }
 }
示例#5
0
        static void Main(string[] args)
        {
            DVD d = new DVD();

            d.id = "CJ";
            d.Play();

            IDisplay anka;

            anka = d;

            d.id = "XXX671";

            anka.Play();

            Washer w = new Washer();

            w.Play();

            anka = w;
            anka.Play();


            anka = new BluRay();
            anka.Play();

            List <IDisplay> machines = new List <IDisplay>();

            machines.Add(new Washer());
            machines.Add(new DVD()
            {
                id = "UYUYUYU"
            });
            machines.Add(new BluRay());

            foreach (var item in machines)
            {
                Console.WriteLine(item.GetType().Name);
                item.Play();

                if (item.GetType().Name == "DVD")
                {
                    Console.WriteLine(((DVD)item).id);
                }
            }
        }
示例#6
0
 //Delete
 public ActionResult Delete(int id)
 {
     using (MyDbContext db = new MyDbContext())
     {
         BluRay blueRay = db.BluRays.FirstOrDefault(u => u.Id == id);
         if (blueRay != null)
         {
             db.Entry(blueRay).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(HttpNotFound());
         }
     }
 }