public async Task <IActionResult> PutDepartment(int id, Department department) { if (id != department.DbID) { return(BadRequest()); } _context.Entry(department).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployees(string id, Employees employees) { if (id != employees.ID) { return(BadRequest()); } _context.Entry(employees).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private async Task <ImmagineRegalo> createOrUpdateImmagineRegalo(byte[] Immagine, string IdImmagineRegalo) { ImmagineRegalo immRegalo; if (IdImmagineRegalo != null) { immRegalo = await dbDataContext.ImmagineRegalo.FindAsync(new Guid(IdImmagineRegalo)); dbDataContext.ImmagineRegalo.Attach(immRegalo); dbDataContext.Entry(immRegalo).State = EntityState.Modified; } else { immRegalo = new ImmagineRegalo(); dbDataContext.ImmagineRegalo.Attach(immRegalo); dbDataContext.Entry(immRegalo).State = EntityState.Added; } immRegalo.Immagine = Immagine; return(immRegalo); }
public bool Update(TEntity item) { bool saveFailed; do { saveFailed = false; try { _db.Entry(item).State = EntityState.Modified; return(true); } catch (DbUpdateConcurrencyException ex) { saveFailed = true; var entry = ex.Entries.Single(); entry.OriginalValues.SetValues(entry.GetDatabaseValues()); } } while (saveFailed); return(true); }
public void Update(User user) { _context.Entry(user).State = System.Data.Entity.EntityState.Modified; Commit(); }