public ActionResult _JoinWithFinePrint(string id, string userType, bool accepted) { if (accepted) { if (!string.IsNullOrEmpty(userType)) { using (var programUserProvider = new ProgramUserProvider()) { var programUsers = programUserProvider.GetForProgram(id, ProgramUserTypes.Participant); if (!programUsers.Any(x => x.UserId.Equals(SessionVariables.CurrentUser.Id))) { var programUser = new ProgramUserSD { Id = DataAccess.Utilities.GenerateUniqueID(), DateCreated = DateTime.Now, ProgramId = id, UserId = SessionVariables.CurrentUser.Id, UserType = userType, Status = ProgramUserStatus.Active }; programUserProvider.Insert(programUser); AlertMessage = "<strong>Congratulations!</strong> You have successfully joined this program. If you have any questions, please contact the program administrator or sponsor. Share the news with your friends! <div class='fb-share-button' data-href='" + ApplicationCache.Instance.SiteUrl + "/Site/ViewProgram/" + id + "' style='vertical-align: middle;'></div>"; AlertMessageType = AlertMessageTypes.Success; } else { AlertMessage = "<strong>Uh oh!</strong> It looks like you are already a participant of this program."; AlertMessageType = AlertMessageTypes.Failure; } return RedirectTo("/Site/ViewProgram/" + id); } } else { ModelState.AddModelError("", "Please select if you are a volunteer or participant"); } } else { ModelState.AddModelError("", "Please agree to the terms"); } using (var provider = new ProgramProvider()) { var program = provider.GetProgram(id); return PartialView("_Join", program); } }
public ActionResult _MakeProgramUser(string programUserId, string programUserType) { using (var programUserProvider = new ProgramUserProvider()) { var programUser = programUserProvider.Get(programUserId); if (ProgramUserTypes.Items.Contains(programUserType)) { programUser.UserType = programUserType; programUserProvider.Update(programUser); AlertMessage = string.Format("You have successfully made this program user a {0}.", programUser.UserType); AlertMessageType = AlertMessageTypes.Success; } else { AlertMessage = "<strong>" + programUserType + "</strong> is not a valid program user type."; AlertMessageType = AlertMessageTypes.Failure; } return Redirect("/Programs/Edit/" + programUser.ProgramId); } }
public ActionResult _RemoveProgramUser(string programUserId) { using (var programUserProvider = new ProgramUserProvider()) { var programUser = programUserProvider.Get(programUserId); programUserProvider.Delete(programUserId); AlertMessage = string.Format("You have successfully removed a program user."); AlertMessageType = AlertMessageTypes.Success; return Redirect("/Programs/Edit/" + programUser.ProgramId); } }
public ActionResult _AddProgramUser(ProgramUserSD item) { if (ModelState.IsValid) { using (var provider = new ProgramUserProvider()) { item.Id = DataAccess.Utilities.GenerateUniqueID(); item.Status = ProgramUserStatus.Pending; provider.Insert(item); var email = new EmailSD { Id = DataAccess.Utilities.GenerateUniqueID(), DateCreated = DateTime.Now, To = item.InvitedEmail, Subject = "Village Creed - Invite", Message = string.Format( "<p>Hi,</p><p>{0} has sent you an invite to join a program as a {1}. You can view this invite by clicking the URL below.</p><p><a href='{2}'>{2}</a></p><p>- The Village Creed Team</p>", SessionVariables.CurrentUser.DisplayName, item.UserType.ToLower(), ApplicationCache.Instance.SiteUrl + "/Dashboard/ViewProgramInvite/" + item.Id) }; Emailer.SendEmail(email); return RedirectTo("/Programs/Edit/" + item.ProgramId); } } return PartialView("_AddProgramUser", item); }
public ActionResult _AddUser(ProgramUserSD item) { if (!string.IsNullOrEmpty(item.UserId)) { using (var provider = new ProgramUserProvider()) { item.Id = DataAccess.Utilities.GenerateUniqueID(); item.Status = ProgramUserStatus.Pending; provider.Insert(item); AlertMessage = "Successfully added a new user to the " + item.UserType + "group"; AlertMessageType = AlertMessageTypes.Success; return RedirectTo("/Programs/Edit/" + item.ProgramId); } } ModelState.AddModelError("", "Please select a user"); return PartialView("_AddUser", item); }
public ActionResult Leave(string programUserId, string programId) { using (var provider = new ProgramUserProvider()) { provider.Delete(programUserId); AlertMessage = "<strong>Sorry to see you go!</strong> You have successfully left this program. If you have any questions, please contact the program administrator or sponsor."; AlertMessageType = AlertMessageTypes.Failure; return Redirect("/Site/ViewProgram/" + programId); } }