public EmailResult NewJob(EmailModel model) { To.Add(model.To); From = model.From; Subject = "Новая задача \""+model.job.name+"\""; return Email("NewJob", model); }
public ActionResult Create(int eid, [Bind(Include = "ID,deadLine,name,description,report,userID")] Job job) { var id = User.Identity.GetUserId(); Event current = db.events.Include(e => e.Jobs).Where(e => e.ID == eid).First(); job.authorID = id; ViewBag.linkedEvent = current; if (ModelState.IsValid) { db.Jobs.Add(job); current.Jobs.Add(job); db.SaveChanges(); EmailModel email = new EmailModel(); email.job = job; email.From = "*****@*****.**"; email.To = userdb.Users.Where(u => u.Id == job.userID).First().Email; new EmailController().NewJob(email).Deliver(); return RedirectToAction("Details", "Events", new { id = eid }); } return View(job); }
public ActionResult Edit(int? eid, [Bind(Include = "ID,deadLine,name,description,report,authorID,userID")] Job job) { if (eid == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } ViewBag.linkedEvent = db.events.Include(e => e.subCategory).Include(e => e.subCategory.parent).Where(e => e.ID == eid).FirstOrDefault(); if (ModelState.IsValid) { db.Entry(job).State = EntityState.Modified; db.SaveChanges(); EmailModel email = new EmailModel(); email.job = job; email.From = "*****@*****.**"; email.To = userdb.Users.Where(u => u.Id == job.userID).First().Email; new EmailController().NewJob(email).Deliver(); return RedirectToAction("Details", new { id = job.ID, eid = eid }); } return View(job); }