protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { return; } var rsvp = new GuestResponse(); if (!TryUpdateModel(rsvp, new FormValueProvider(ModelBindingExecutionContext))) { return; } ResponseRepository.GetRepository().AddResponse(rsvp); if (rsvp.WillAttend.HasValue && rsvp.WillAttend.Value) { Response.Redirect("seeyouthere.html"); } else { Response.Redirect("sorryyoucantcome.html"); } }
protected void Page_Load(object sender, EventArgs e) { // We determine if the request we are responding to is the form being posted back to the server by checking the IsPostBack property if (IsPostBack) { // we create a new instance of the GuestResponse data model object GuestResponse rsvp = new GuestResponse(); // The TryUpdateModel method performs a process called model binding where data values are used // from the browser request to populate the properties of our data model object if (TryUpdateModel(rsvp, new FormValueProvider(ModelBindingExecutionContext))) { // We then store the GuestResponse object in our repository. ResponseRepository.GetRepository().AddResponse(rsvp); // If the WillAttend property is true, then the user is coming to the party and we redirect him or her to the seeyouthere.html file. if (rsvp.WillAttend.HasValue && rsvp.WillAttend.Value) { Response.Redirect("seeyouthere.html"); } else { // Otherwise, we redirect the user to the sorryyoucantcome.html file. Response.Redirect("sorryyoucantcome.html"); } } } }
protected string GetNoShowHtml() { StringBuilder html = new StringBuilder(); var noData = ResponseRepository.GetRepository().GetAllResponses().Where(r => r.WillAttend.HasValue && r.WillAttend.Value == false); foreach (var rsvp in noData) { html.Append(String.Format($"<tr><td>{rsvp.Name}</td><td>{rsvp.Email}</td><td>{rsvp.Phone}</td></tr>")); } return(html.ToString()); }
public string GetNoShowHtml() { StringBuilder html = new StringBuilder(); var noData = ResponseRepository.GetRepository().GetAllResponses().Where(r => r.WillAttend.HasValue && r.WillAttend.Value); foreach (var rsvp in noData) { html.Append(string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>", rsvp.Name, rsvp.Email, rsvp.Phone)); } return(html.ToString()); }
protected string GetYes() { var yesData = ResponseRepository.GetRepository().GetAllResponses() .Where(r => r.WillAttend.HasValue && r.WillAttend.Value); var html = new StringBuilder(); foreach (var rsvp in yesData) { html.Append($"<tr><td>{rsvp.Name}</td><td>{rsvp.Email}</td><td>{rsvp.Phone}</td></tr>"); } return(html.ToString()); }