예제 #1
0
        public ActionResult Create([Bind(Include = "Id,AlbumName,Artist")] Album album)
        {
            if (ModelState.IsValid)
            {
                db.Albums.Add(album);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(album));
        }
        public bool Create(Album model)
        {
            try
            {
                model.CreatedAt             = DateTime.Now;
                _context.Entry(model).State = EntityState.Added;
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }