/// <summary> /// Update Program /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdateProgram_Click(object sender, EventArgs e) { try { int campaignID = ValidationHelper.GetInteger(ddlCampaign.SelectedValue, 0); TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); if (Page.IsValid) { if (ViewState["programNodeID"] != null) { if (ValidationHelper.GetDate(txtProgramDeliveryDate.Text, default(DateTime)).Date >= DateTime.Today) { Program program = ProgramProvider.GetProgram(ValidationHelper.GetInteger(ViewState["programNodeID"], 0), CurrentDocument.DocumentCulture, CurrentSiteName); if (program != null) { program.DocumentName = txtProgramName.Text; program.ProgramName = txtProgramName.Text; program.ProgramDescription = txtProgramDescription.Text; program.BrandID = ValidationHelper.GetInteger(ddlBrand.SelectedValue, 0); program.CampaignID = ValidationHelper.GetInteger(ddlCampaign.SelectedValue, 0); program.Status = ValidationHelper.GetBoolean(ddlStatus.SelectedValue, true); program.DeliveryDateToDistributors = ValidationHelper.GetDate(txtProgramDeliveryDate.Text, default(DateTime)).Date; program.Update(); } if (ViewState["CampaignID"] != null) { if (Convert.ToInt32(ViewState["CampaignID"]) != campaignID) { Campaign targetCampaign = CampaignProvider.GetCampaigns().WhereEquals("CampaignID", campaignID).FirstOrDefault(); if (targetCampaign != null && program != null) { DocumentHelper.MoveDocument(program, targetCampaign, tree, true); } } } Response.Cookies["status"].Value = QueryStringStatus.Updated; Response.Cookies["status"].HttpOnly = false; URLHelper.Redirect($"{CurrentDocument.Parent.DocumentUrlPath}?status={QueryStringStatus.Updated}"); } } } } catch (Exception ex) { EventLogProvider.LogInformation("CMSWebParts_Kadena_Programs_AddNewProgram", "btnUpdateProgram_Click", ex.Message); } }
public new ActionResult View(string id) { using (var provider = new ProgramProvider()) { var program = provider.GetProgram(id, true); if(program.Program.BlockedBy17) { if (SessionVariables.CurrentUser != null && SessionVariables.CurrentUser.Age < 17) { return View("Blocked", program); } return View(program); } else { return View(program); } } }
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 _DeleteComment(string id, string programId) { using (var provider = new ProgramCommentProvider()) { provider.Delete(id); } using (var provider = new ProgramProvider()) { var program = provider.GetProgram(programId); return PartialView("_Comments", program); } }
public ActionResult _AddComment(ProgramCommentSD model) { using (var provider = new ProgramCommentProvider()) { model.Id = DataAccess.Utilities.GenerateUniqueID(); model.DateCreated = DateTime.Now; model.UserId = SessionVariables.CurrentUser.Id; provider.Insert(model); } using (var provider = new ProgramProvider()) { var program = provider.GetProgram(model.ProgramId); return PartialView("_Comments", program); } }
public ActionResult Cancel(string id) { using (var programProvider = new ProgramProvider()) { var program = programProvider.GetProgram(id); if (!program.ProgramUsers.Any(x => x.UserType.Equals(ProgramUserTypes.Administrator) && x.UserId.Equals(SessionVariables.CurrentUser.Id)) && !SessionVariables.CurrentUser.SuperAdmin) { return RedirectToAction("AccessDenied", "Error"); } program.Program.Status = ProgramStatus.Cancelled; programProvider.Update(program.Program); return DefaultRedirect; } }
public ActionResult Edit(string id) { using (var provider = new ProgramProvider()) { var item = provider.GetProgram(id); if (!item.ProgramUsers.Where(x => !string.IsNullOrEmpty(x.UserId)).Any(x => x.UserType.Equals(ProgramUserTypes.Administrator) && x.UserId.Equals(SessionVariables.CurrentUser.Id)) && !SessionVariables.CurrentUser.SuperAdmin) { return RedirectToAction("AccessDenied", "Error"); } return View(DefaultViews.CreateEdit, item); } }