public ActionResult Create(PledgeContributors pledgeContributors) { pledgeContributors.Sinner = CurrentUser(); pledgeContributors.SinnerID = CurrentUser().Id; ModelState.Clear(); TryValidateModel(pledgeContributors); var UserMessage = ""; var ErrorMessage = ""; if (pledgeContributors.IsOriginator) { UserMessage = "Excellent! Thank you. Your new pledge has been created."; ErrorMessage = "There was a problem trying to create your new pledge. Sorry."; } else { UserMessage = "Excellent! Thank you. you have been added as co-sponsor to this pledge."; ErrorMessage = "There was a problem trying to add your co-sponsorship to this pledge. Sorry."; } if (ModelState.IsValid) { db.PledgeContributors.Add(pledgeContributors); BusinessLogic.Messaging.Add(Message.LevelEnum.alert_success, UserMessage, Message.TypeEnum.StickyAlert, CurrentUser()); } else { BusinessLogic.Messaging.Add(Message.LevelEnum.alert_danger, ErrorMessage, Message.TypeEnum.TemporaryAlert, CurrentUser()); } db.SaveChanges(); return(RedirectToAction("Details", "Pledges", new { id = pledgeContributors.PledgeID })); }
public static string GetPaymentURL(PledgeContributors contrib, UrlHelper Url, HttpRequestBase Request) { var BaseURL = ConfigurationManager.AppSettings["JustGivingURL"]; var PayURL = BaseURL + "4w350m3/donation/direct/charity/" + contrib.Pledge.Charity.JustGivingCharityID + "?"; PayURL += "amount=" + contrib.Amount; PayURL += "¤cy=" + contrib.Currency; PayURL += "&reference=" + contrib.ID; PayURL += "&exitURL=" + Url.Action("PaymentComplete", "Pledges", new { id = contrib.ID }, Request.Url.Scheme); return(PayURL); }
public static SocialVM GetSocialVMForPledgeContribution(PledgeContributors PC, string PCIdent, HttpRequestBase Request, UrlHelper Url) { string blurb; if (PC.AmountAnonymous) { blurb = $"{PC.Sinner.UserName} made a pledge to {PC.Pledge.Charity.Name}"; } else { blurb = $"{PC.Sinner.UserName} pledged {CurrencyLogic.GetCurrencyPrefix(PC.Currency)}{PC.Amount} to {PC.Pledge.Charity.Name}"; } return(new SocialVM() { Type = SocialVM.SocialType.PledgeContribution, LinkID = PC.ID.ToString(), ShareURL = Url.Action("Details", "Pledges", new { id = PC.Pledge.PledgeID }, protocol: Request.Url.Scheme) + "#" + PCIdent, Blurb = blurb }); }