protected void btnWrite_Click(object sender, EventArgs e)
        {
            // 보안 문자를 정확히 입력했거나, 로그인이 된 상태라면...
            if (IsImageTextCorrect())
            {
                UploadProcess(); // 파일 업로드 관련 코드 분리

                ArticleBase note = new ArticleBase();

                note.Id = Convert.ToInt32(_Id);

                note.Name     = txtName.Text;
                note.Email    = Dul.HtmlUtility.Encode(txtEmail.Text);
                note.Homepage = txtHomepage.Text;
                note.Title    = Dul.HtmlUtility.Encode(txtTitle.Text);
                note.Content  = txtContent.Text;
                note.FileName = _FileName;
                note.FileSize = _FileSize;
                note.Password = txtPassword.Text;
                note.PostIp   = Request.UserHostAddress;
                note.Encoding = rdoEncoding.SelectedValue;

                CongressRepository repository = new CongressRepository();

                switch (FormType)
                {
                case BoardWriteFormType.Write:
                    repository.Add(note);
                    Response.Redirect("CongressList.aspx");
                    break;

                case BoardWriteFormType.Modify:
                    note.ModifyIp = Request.UserHostAddress;
                    note.FileName = ViewState["FileName"].ToString();
                    note.FileSize = Convert.ToInt32(ViewState["FileSize"]);
                    int r = repository.UpdateNote(note);
                    if (r > 0)     // 업데이트 완료
                    {
                        Response.Redirect($"CongressView.aspx?Id={_Id}");
                    }
                    else
                    {
                        lblError.Text =
                            "업데이트가 되지 않았습니다. 암호를 확인하세요.";
                    }
                    break;

                case BoardWriteFormType.Reply:
                    note.ParentNum = Convert.ToInt32(_Id);
                    repository.ReplyNote(note);
                    Response.Redirect("CongressList.aspx");
                    break;

                default:
                    repository.Add(note);
                    Response.Redirect("CongressList.aspx");
                    break;
                }
            }
            else
            {
                lblError.Text = "보안코드가 틀립니다. 다시 입력하세요.";
            }
        }
        private void DisplayData()
        {
            var repository = new CongressRepository();

            Model = repository.GetAll(0, 5); // 썸네일 4개 가져오기
        }
 public BoardDown()
 {
     _repository = new CongressRepository();
 }
Example #4
0
 public CongressList()
 {
     _repository = new CongressRepository();
 }