コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: ExerciseController.cs プロジェクト: jfreal/movidhep
        public ActionResult Create(ExerciseViewModel postedModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(postedModel));
                }

                //this code could use some TLC

                var newExercise = new Exercise();

                string[] lines = postedModel.Categories.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
                newExercise.Categories = new List <string>(lines.Where(x => !string.IsNullOrWhiteSpace(x)));


                if (!string.IsNullOrWhiteSpace(postedModel.VideoId))
                {
                    newExercise.VideoId = postedModel.VideoId.Trim();
                }

                Ownership.Assign(newExercise, this);

                if (this.ApplicationAdministrator)
                {
                    newExercise.Master = true;
                }
                newExercise.CreatedOn   = DateTime.Now;
                newExercise.Name        = postedModel.Name.Trim();
                newExercise.Description = postedModel.Description;

                RavenSession.Store(newExercise);
                RavenSession.SaveChanges();

                if (!string.IsNullOrWhiteSpace(postedModel.VideoId))
                {
                    var success = Thumbnailer.GenerateThumbs(newExercise.Id, newExercise.VideoId);
                    if (!success)
                    {
                        this.WarnUser("We couldn't generate a thumbnail image for this exercise.  The video id could be wrong or Vimeo may be not be " +
                                      "responding.  We'll try to generate the thumbnail again but it would be a good idea to double" +
                                      "check the video id. Sorry about that.");
                    }
                }

                HighFive("New exercise created ok.");

                return(RedirectToAction("List"));
            }
            catch
            {
                return(View(postedModel));
            }
        }
コード例 #3
0
        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));
        }
コード例 #4
0
ファイル: UserApiController.cs プロジェクト: jfreal/movidhep
        public ApiResponse AddUser(UserPostedModel postedModel)
        {
            var existingUserWithSameEmail =
                RavenSession.Query <User>()
                .Any(x => x.AccountId == LoggedInUser.AccountId && x.Email == postedModel.Email);

            if (existingUserWithSameEmail)
            {
                return(new ApiResponse(error: "A user with this email already exists"));
            }

            var user = new User()
            {
                Name      = postedModel.Name,
                Status    = UserStatus.Invited,
                Email     = postedModel.Email,
                ClinicIds = new List <int>()
                {
                    postedModel.ClinicId
                },
                CreatedOn = DateTime.Now,
                AccountId = LoggedInUser.AccountId
            };

            RavenSession.Store(user);

            var invitation = new UserInvitation()
            {
                ClinicId = postedModel.ClinicId,
                ToUserId = user.Id,
                Created  = DateTime.Now
            };

            Ownership.Assign(invitation, this);
            invitation.ClinicId = postedModel.ClinicId;

            RavenSession.Store(invitation);
            RavenSession.SaveChanges();

            SendInvitation(invitation, user);

            return(new ApiResponse(success: "User created")
            {
                Model = user
            });
        }
コード例 #5
0
ファイル: ProtocolController.cs プロジェクト: jfreal/movidhep
        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"));
        }