Exemple #1
0
        // GET: Home
        public ActionResult Index()
        {
            var query = from t in db.TobeSends
                        where (t.SendTime <= DateTime.Now && t.SendStatus == "To be Send")
                        select t;

            foreach (TobeSend x in query)
            {
                SentWarning y = new SentWarning
                {
                    MailSent      = x.ContactDetail.UseMail,
                    SMSSent       = x.ContactDetail.UseSMS,
                    SentTime      = x.SendTime,
                    ContactDetail = x.ContactDetail,
                    Warning       = x.Warning
                };
                db.SentWarnings.Add(y);
                x.SendStatus = "Has Been Sent";
            }
            db.SaveChanges();

            var tobeSends = db.TobeSends.Include(t => t.ContactDetail).Include(t => t.Warning);

            ViewBag.tobeSends = tobeSends;

            return(View(tobeSends.ToList()));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SentWarning sentWarning = db.SentWarnings.Find(id);

            db.SentWarnings.Remove(sentWarning);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,MailSent,SMSSent,SentTime,ContactDetailID,WarningID")] SentWarning sentWarning)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sentWarning).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ContactDetailID = new SelectList(db.ContactDetails, "Id", "Name", sentWarning.ContactDetailID);
     ViewBag.WarningID       = new SelectList(db.Warnings, "Id", "Title", sentWarning.WarningID);
     return(View(sentWarning));
 }
        // GET: SentWarnings/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SentWarning sentWarning = db.SentWarnings.Find(id);

            if (sentWarning == null)
            {
                return(HttpNotFound());
            }
            return(View(sentWarning));
        }
        // GET: SentWarnings/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SentWarning sentWarning = db.SentWarnings.Find(id);

            if (sentWarning == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ContactDetailID = new SelectList(db.ContactDetails, "Id", "Name", sentWarning.ContactDetailID);
            ViewBag.WarningID       = new SelectList(db.Warnings, "Id", "Title", sentWarning.WarningID);
            return(View(sentWarning));
        }