Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
 public void Update(Worker worker)
 {
     db.Entry(worker).State = EntityState.Modified;
 }
Ejemplo n.º 6
0
 public void Update(TEntity item)
 {
     _context.Entry(item).State = _context.Entry(item).State;
     _context.SaveChanges();
 }