示例#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());
        }
 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));
 }
 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));
 }
 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));
 }
        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();
 }