public ActionResult NewProgram(Program newProgram) { if (string.IsNullOrWhiteSpace(newProgram.Email)) { return(Json(new { success = false })); } newProgram.ShortUrl = ShortUrl.Create(); newProgram.Created = DateTime.Now; Ownership.Assign(newProgram, this); if (!LoggedInUser.OnboardingTasks.Contains(OnboardingTask.CreatedProgram.ToString())) { LoggedInUser.OnboardingTasks.Add(OnboardingTask.CreatedProgram.ToString()); } RavenSession.Store(newProgram); RavenSession.SaveChanges(); new Emailer(this).SendEmail(EmailEnum.SendToPatient, newProgram.Email, newProgram.ShortUrl, newProgram.Id); // new ProgramEmailer(this).SendToPatient(newProgram.Id, newProgram.Email, newProgram.ShortUrl); return(Json(true)); }
public ActionResult NewProtocol(Protocol postedProtocol) { postedProtocol.ShortUrl = ShortUrl.Create(); postedProtocol.Created = DateTime.Now; Ownership.Assign(postedProtocol, this); RavenSession.Store(postedProtocol); RavenSession.SaveChanges(); return(Json(true)); }
public ActionResult QuickSend(string email, int protocolId) { var protocol = RavenSession.Load <Protocol>("protocols/" + protocolId); if (string.IsNullOrWhiteSpace(email)) { return(Json(new { success = false })); } if (protocol == null) { return(HttpNotFound()); } var newProgram = new Program() { Email = email }; Ownership.Assign(newProgram, this); newProgram.Exercises = protocol.Exercises; newProgram.Greeting = Account.Settings.DefaultGreeting; newProgram.ShortUrl = ShortUrl.Create(); newProgram.Created = DateTime.Now; RavenSession.Store(newProgram); RavenSession.SaveChanges(); new ProgramEmailer(this).SendToPatient(newProgram.Id, newProgram.Email, newProgram.ShortUrl); var highFive = string.Format("Protocol {0} sent to {1}", protocol.Name, newProgram.Email); HighFive(highFive); return(RedirectToAction("List")); }