// 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)); }
// 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ı)); }
// 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)); }
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ı)); }
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ı)); }