コード例 #1
0
        public async Task <IActionResult> PutSample(int id, Sample sample)
        {
            if (id != sample.SampleId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "productId,productName,price,stock")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
コード例 #3
0
 public ActionResult Edit(Supplier supplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplier));
 }
コード例 #4
0
 public ActionResult Manage([Bind(Include = "ProjectID,Title,Description,Phase")] Project project)
 {
     if (ModelState.IsValid)
     {
         db.Entry(project).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(project));
 }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "CardID,ProjectID,Status,Title,Description")] Card card)
 {
     if (ModelState.IsValid)
     {
         db.Entry(card).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(card));
 }
コード例 #6
0
        public T Update(T entity)
        {
            T originalEntity = Get(entity.Id);

            if (originalEntity == null)
            {
                return(null);
            }

            _context.Entry(originalEntity).CurrentValues.SetValues(entity);
            //_context.BaseEntitys.Update(originalEntity);
            _context.SaveChanges();
            return(entity);
        }
コード例 #7
0
ファイル: Repository.cs プロジェクト: 1412579/PM
 public void Update(TEntity entity)
 {
     _context.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
 }
コード例 #8
0
 public async Task Update(T entity)
 {
     _pmContext.Entry(entity).State = EntityState.Modified;
     await _pmContext.SaveChangesAsync();
 }