public ActionResult DeleteConfirmed(int id) { RobotsLog robotsLog = db.RobotsLogs.Find(id); db.RobotsLogs.Remove(robotsLog); db.SaveChanges(); return(RedirectToAction("AddLog")); }
public ActionResult Edit([Bind(Include = "Id,TimeStamp,RobId")] RobotsLog robotsLog) { if (ModelState.IsValid) { db.Entry(robotsLog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RobId = new SelectList(db.Robots, "RobId", "Beskrivning", robotsLog.RobId); return(View(robotsLog)); }
public ActionResult Create([Bind(Include = "Id,TimeStamp,RobId")] RobotsLog robotsLog) { if (ModelState.IsValid) { db.RobotsLogs.Add(robotsLog); db.SaveChanges(); return(RedirectToAction("AddLog")); } ViewBag.RobId = new SelectList(db.Robots, "RobId", "Beskrivning", robotsLog.RobId); return(View(robotsLog)); }
// GET: RobotsLogs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RobotsLog robotsLog = db.RobotsLogs.Find(id); if (robotsLog == null) { return(HttpNotFound()); } return(View(robotsLog)); }
// GET: RobotsLogs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RobotsLog robotsLog = db.RobotsLogs.Find(id); if (robotsLog == null) { return(HttpNotFound()); } ViewBag.RobId = new SelectList(db.Robots, "RobId", "Beskrivning", robotsLog.RobId); return(View(robotsLog)); }
// GET: RobotsLogs public ActionResult AddLog(int?id) { Robot robot = db.Robots.Where(r => r.RobId == id).FirstOrDefault(); RobotsLog robotLog = new RobotsLog { TimeStamp = DateTime.Now, RobId = id }; if (robot != null) { robot.MailSended = false; db.RobotsLogs.Add(robotLog); db.SaveChanges(); } return(View(db.RobotsLogs.OrderByDescending(r => r.TimeStamp).ToList())); }
public void SendEmail(Robot robot, string emailbody) { RobotsLog robotsLog = new RobotsLog(); if (robot.ContactInfo != null) { MailMessage mail = new MailMessage("", robot.ContactInfo); mail.Subject = "Loggen är inte mottagen"; mail.Body = emailbody; SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587); smtpClient.Credentials = new NetworkCredential("", ""); smtpClient.EnableSsl = true; smtpClient.Send(mail); } }