コード例 #1
0
        public async Task <IActionResult> PutMovie(int id, Movie movie)
        {
            if (id != movie.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PutReview([FromRoute] int id, [FromBody] Review review)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
コード例 #3
0
        public TEntity Update(TEntity obj)
        {
            var resut = table.Attach(obj);

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

            return(resut.Entity);
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Id,Title,ReleaseDate,Genre,Price")] Movie movie)
 {
     if (ModelState.IsValid)
     {
         db.Entry(movie).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(movie));
 }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "ID,Title,Genre,Price,ReleaseDate,Rating")] Film film)
 {
     if (ModelState.IsValid)
     {
         db.Entry(film).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(film));
 }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "ProductID,Name,Price,Active")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
コード例 #7
0
 public void Update(TEntity obj)
 {
     table.Attach(obj);
     _context.Entry(obj).State = EntityState.Modified;
 }