public async Task <ActionResult <RobotModel> > PostRobotModel(long id) { var robot = await _context.Robots.FindAsync(id); if (robot is null) { return(NotFound()); } RobotReset robotReset = new RobotReset(); robotReset.Reset(robot); _context.Entry(robot).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(NoContent()); }
public void LateLogSendEmail() { RobotsLog Log; var robotList = db.Robots.ToList(); foreach (Robot item in robotList) { Log = db.RobotsLogs .Where(i => i.RobId == item.RobId) .OrderByDescending(i => i.TimeStamp) .FirstOrDefault(); if (Log == null) { item.MailSended = true; } else if (DateTime.Now - Log.TimeStamp > TimeSpan.FromMinutes(item.IntPuls)) { if (item.MailSended == false) { SendEmail(item, item.Beskrivning + " " + "Senaste skickad logg" + " " + Log.TimeStamp); if (ModelState.IsValid) { Robot robot = db.Robots.Where(r => r.RobId == item.RobId).FirstOrDefault(); robot.MailSended = true; db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } } } } }
/* * The response is 204 (No Content). According to the HTTP specification, * a PUT request requires the client to send the entire updated entity, not just the changes. */ public async Task <IActionResult> PutRobot(int id, Robot robot) { if (id != robot.IdRobot) { return(BadRequest()); } _context.Entry(robot).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RobotExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "RobId,Beskrivning,IntPuls,ContactInfo")] Robot robot) { if (ModelState.IsValid) { db.Entry(robot).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(robot)); }
public ActionResult Edit([Bind(Include = "Id,Nome,Idade")] Pessoa pessoa) { if (ModelState.IsValid) { db.Entry(pessoa).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pessoa)); }
public async Task UpdateAsync(T entity) { _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); }