public Worker Action() { using WorkerContext db = new WorkerContext(); Chief.SubWorkers.Add(Person); db.Entry(Chief).State = EntityState.Modified; Person.Chief = Chief; db.Entry(Person).State = EntityState.Modified; db.SaveChanges(); return(Chief); }
public Worker Action() { using (WorkerContext db = new WorkerContext()) { Chief.SubWorkers = SubWorkers; db.Entry(Chief).State = EntityState.Modified; foreach (var t in db.Workers) { t.Chief = Chief; db.Entry(t).State = EntityState.Modified; } } return(Chief); }
public async Task <IActionResult> PutWorker([FromRoute] int id, [FromBody] Worker worker) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != worker.Id) { return(BadRequest()); } _context.Entry(worker).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,Name,Position,Birthday")] Worker worker) { if (ModelState.IsValid) { db.Entry(worker).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(worker)); }
public void Update(Worker worker) { db.Entry(worker).State = EntityState.Modified; }
public void Update(TEntity item) { _context.Entry(item).State = _context.Entry(item).State; _context.SaveChanges(); }