コード例 #1
0
 public ActionResult Edit([Bind(Include = "Id,AlbumName,Artist")] Album album)
 {
     if (ModelState.IsValid)
     {
         db.Entry(album).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(album));
 }
コード例 #2
0
        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);
        }