示例#1
0
        // GET: Hatırlatıcı/Create
        public ActionResult Create(int id)
        {
            HatırlatıcıModel model = new HatırlatıcıModel()
            {
                MachineId = id,
            };

            return(View(model));
        }
示例#2
0
        // GET: Hatırlatıcı/Details/5
        public ActionResult Details(int id)
        {
            HatırlatıcıModel hatırlatıcı = hatService.GetById(id);

            if (hatırlatıcı == null)
            {
                return(HttpNotFound());
            }
            return(View(hatırlatıcı));
        }
示例#3
0
        // GET: Hatırlatıcı/Delete/5
        public ActionResult Delete(int id)
        {
            HatırlatıcıModel model = hatService.GetById(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
示例#4
0
 public ActionResult Edit(HatırlatıcıModel hatırlatıcı)
 {
     if (ModelState.IsValid)
     {
         var entity = hatService.GetById(hatırlatıcı.Id);
         entity.Name      = hatırlatıcı.Name;
         entity.Details   = hatırlatıcı.Details;
         entity.DateTime  = hatırlatıcı.DateTime;
         entity.MachineId = hatırlatıcı.MachineId;
         hatService.Update(entity);
         hatService.SaveChanges();
         return(RedirectToAction("Sergi", new { id = hatırlatıcı.MachineId }));
     }
     return(View(hatırlatıcı));
 }
示例#5
0
        public ActionResult Create(HatırlatıcıModel hatırlatıcı)
        {
            var userstring = User.Identity.Name.ToString();
            var user       = userService.GetQuery(q => q.Name == userstring).FirstOrDefault();

            user.Mail = hatırlatıcı.From;
            if (DateTime.Now.ToShortDateString() != hatırlatıcı.DateTime.ToShortDateString())
            {
                ViewBag.Message = "Hatırlatıcı başarı ile oluşturulmuştur.";
            }
            else
            {
                MailMessage mail = new MailMessage(hatırlatıcı.From, hatırlatıcı.To);
                mail.Subject    = hatırlatıcı.Name;
                mail.Body       = hatırlatıcı.Details;
                mail.IsBodyHtml = false;


                SmtpClient smtp = new SmtpClient();
                smtp.Host      = "smtp.gmail.com";
                smtp.Port      = 587;
                smtp.EnableSsl = true;

                NetworkCredential network = new NetworkCredential(hatırlatıcı.From, hatırlatıcı.GmailPassword);
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = network;
                smtp.Send(mail);
            }
            if (ModelState.IsValid)
            {
                hatService.Add(hatırlatıcı);
                hatService.SaveChanges();
                return(RedirectToAction("Sergi", new { id = hatırlatıcı.MachineId }));

                ViewBag.Message = "Hatırlatıcı başarı ile oluşturulmuştur.";
            }

            return(View(hatırlatıcı));
        }