public ActionResult Edit(string id, MessageInfo item)
 {
     try
     {
         PostMessager pm = new PostMessager();
         pm.UpdateItem(Guid.Parse(id), item.Schedule, item.Subject, item.Context);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
        public ActionResult Create(MessageInfo item)
        {
            try
            {
                PostMessager pm = new PostMessager();
                pm.AddNew(item.Schedule, item.Subject, item.Context);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        //public void NewMessage(DateTime? schedule, string subject, string context)
        //{
        //    PostMessager PM = new PostMessager();
        //    PM.AddNew(schedule, subject, context);
        //}
        public void DoDailyPost()
        {
            PostMessager PM = new PostMessager();
            MessageInfo item = PM.GetMessageToPost();
            if(item==null)
                return;

            EmailHelper email = new EmailHelper();
            string email_addr = System.Configuration.ConfigurationManager.AppSettings["mail_to_address"];
            bool result = email.Send(email_addr, item.Subject, item.Context);

            if (result)
            {
                PM.SentMessageComplete(item.Id);
            }
        }
 // GET: DailyMessage
 public ActionResult Index()
 {
     PostMessager pm = new PostMessager();
     List<MessageInfo> data = pm.GetData().Items;
     if (data.Count > 0)
         return View(data);
     else
         return RedirectToAction("Create");
 }
 // GET: DailyMessage/Edit/5
 public ActionResult Edit(string id)
 {
     PostMessager pm = new PostMessager();
     MessageInfo data = pm.GetItem( Guid.Parse(id));
     return View(data);
 }
 // GET: DailyMessage/Delete/5
 public ActionResult Delete(string id)
 {
     PostMessager pm = new PostMessager();
     pm.DeleteItem(Guid.Parse(id));
     return RedirectToAction("Index");
 }