예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            RobotsLog robotsLog = db.RobotsLogs.Find(id);

            db.RobotsLogs.Remove(robotsLog);
            db.SaveChanges();
            return(RedirectToAction("AddLog"));
        }
예제 #2
0
 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));
 }
예제 #3
0
        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));
        }
예제 #4
0
        // 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));
        }
예제 #5
0
        // 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));
        }
예제 #6
0
        // 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()));
        }
예제 #7
0
        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);
            }
        }