コード例 #1
0
        //protected void Page_Load(object sender, EventArgs e)
        //{
        //    erase it !!!
        //}
        protected string GetNoShowHtml()
        {
            StringBuilder html   = new StringBuilder();
            var           noData = ResponseRepository.GetRepository()
                                   .GetAllResponses().Where(r => !r.WillAttend.Value);

            foreach (var rsvp in noData)
            {
                html.Append(String.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td>",
                                          rsvp.Name, rsvp.Email, rsvp.Phone));
            }
            return(html.ToString());
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                Page.Validate();
                if (!Page.IsValid)
                {
                    return;
                }
                GuestResponse rsvp = new GuestResponse(name.Text, email.Text, phone.Text, CheckBoxYN.Checked);

                ResponseRepository.GetRepository().AddResponse(rsvp);
                if (CheckBoxYN.Checked)
                {
                    Report report1 = new Report(TextBoxTitle.Text, TextBoxTextAnnot.Text);
                    rsvp.Reports.Add(report1);
                }
                if (TextBoxTitle2.Text != "" || TextBoxTextAnnot2.Text != "")
                {
                    Report report2 = new Report(TextBoxTitle2.Text, TextBoxTextAnnot2.Text);
                    rsvp.Reports.Add(report2);
                }
                try
                {
                    SampleContext context = new SampleContext();
                    context.GuestResponses.Add(rsvp);
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    Response.Redirect("Ошибка " + ex.Message);
                }

                if (rsvp.WillAttend.HasValue && rsvp.WillAttend.Value)
                {
                    Response.Redirect("seeyouthere1.aspx");
                }
                else
                {
                    Response.Redirect("sorryyoucantcome1.aspx");
                }
            }
        }