public ActionResult SubmitVote(string[] sessionIds, string orderNumber = "", string orderEmail = "") { if (sessionIds.Length != EventConfig.TotalVotes) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } var validOrder = false; var correctEmail = false; if (FeatureFlags.ValiateEventbriteVotes) { var order = _eventbriteService.GetOrder(orderNumber); validOrder = order != null; if (order != null) { correctEmail = order.Email.ToLowerInvariant().Equals(orderEmail.ToLowerInvariant()); } } var votes = new List <Vote>(); for (var i = 0; i < EventConfig.TotalVotes; i++) { votes.Add(new Vote(sessionIds[i], System.Web.HttpContext.Current.Request.UserHostAddress, orderNumber, orderEmail, validOrder, correctEmail)); } _voteService.AddVotes(votes); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public ActionResult SubmitVote(string[] sessionIds, string orderNumber = "", string orderEmail = "") { if (sessionIds.Length != EventConfig.TotalVotes) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } var validOrder = false; var correctEmail = false; if (FeatureFlags.ValiateEventbriteVotes) { var order = _eventbriteService.GetOrder(orderNumber.Trim()); if (order != null) { validOrder = true; if (!string.IsNullOrEmpty(order.Email)) { correctEmail = order.Email.Trim().ToUpperInvariant().Equals(orderEmail.Trim().ToUpperInvariant()); } if (correctEmail == false && order.Attendees != null && order.Attendees.Any()) { correctEmail = order.Attendees.Any(attendee => attendee != null && attendee.Profile != null && !string.IsNullOrEmpty(attendee.Profile.Email) && attendee.Profile.Email.Trim().ToUpperInvariant() .Equals(orderEmail.Trim().ToUpperInvariant())); } } } var votes = new List <Vote>(); for (var i = 0; i < EventConfig.TotalVotes; i++) { votes.Add(new Vote(sessionIds[i], System.Web.HttpContext.Current.Request.UserHostAddress, orderNumber, orderEmail, validOrder, correctEmail)); } _voteService.AddVotes(votes); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }