Exemple #1
0
 public ActionResult EditCharacter(CharacterDB character, int id)
 {
     if (ModelState.IsValid)
     {
         db.Entry(character).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(character));
 }
Exemple #2
0
        public async Task <TEntity> UpdateAsync(TEntity entity)
        {
            var currentEntity = await GetByIdAsync(entity.Id).ConfigureAwait(false);

            EntityContext.Entry(currentEntity).CurrentValues.SetValues(entity);

            await EntityContext.SaveChangesAsync();

            return(entity);
        }
Exemple #3
0
 public Task Update(T entity)
 {
     // In case AsNoTracking is used
     _context.Entry(entity).State = EntityState.Modified;
     return(_context.SaveChangesAsync());
 }