Esempio n. 1
0
        private void DisplayDataForModify()
        {
            //[A] 넘겨온 Id 값에 해당하는 레코드 하나 읽어서 모델 클래스에 바인딩
            var model = new ArticleBase();

            if (AccountHandler.HasGroup("Administrators"))
            {
                model = _repository.GetByIdAdmin(Convert.ToInt32(_Id));
            }
            else
            {
                model = _repository.GetById(Convert.ToInt32(_Id), _userName);
            }

            //[B] 각각의 항목을 컨트롤(레이블, 텍스트박스, ...)에 출력
            ddlCategoryList.SelectedValue = model.Category; // 기존 값 선택
            txtName.Text     = model.Name;
            txtEmail.Text    = model.Email;
            txtHomepage.Text = model.Homepage;
            txtTitle.Text    = model.Title;
            txtContent.Text  = model.Content;

            //[C] 인코딩 방식에 따른 데이터 출력
            string strEncoding = model.Encoding;

            if (strEncoding == "Text") // Text : 소스 그대로 표현
            {
                rdoEncoding.SelectedIndex = 0;
            }
            else if (strEncoding == "Mixed") // Mixed : 엔터처리만
            {
                rdoEncoding.SelectedIndex = 2;
            }
            else // HTML : HTML 형식으로 출력
            {
                rdoEncoding.SelectedIndex = 1;
            }

            //[D] 첨부된 파일명 및 파일크기 기록
            if (model.FileName.Length > 1)
            {
                ViewState["FileName"] = model.FileName;
                ViewState["FileSize"] = model.FileSize;

                pnlFile.Height = 50;
                lblFileNamePrevious.Visible = true;
                lblFileNamePrevious.Text    = $"기존에 업로드된 파일명: {model.FileName}";
            }
            else
            {
                ViewState["FileName"] = "";
                ViewState["FileSize"] = 0;
            }
        }
        // 특정 사용자의 전체 레코드 수
        public int GetSupportsCount()
        {
            using (var db = new SupportContext())
            {
                string userName = HttpContext.Current.Session["UserName"].ToString();

                if (AccountHandler.HasGroup("Administrators"))
                {
                    // 관리자면 전체 레코드 수
                    return(db.Supports.Count());
                }
                else
                {
                    // 일반 사용자면 자신이 쓴 글에 대한 레코드 수
                    return(db.Supports.Where(s => s.UserName == userName).Count());
                }
            }
        }
Esempio n. 3
0
        private void DisplayDataForReply()
        {
            // 넘겨온 Id 값에 해당하는 레코드 하나 읽어서 모델 클래스에 바인딩
            var model = new ArticleBase();

            if (AccountHandler.HasGroup("Administrators"))
            {
                model = _repository.GetByIdAdmin(Convert.ToInt32(_Id));
            }
            else
            {
                model = _repository.GetById(Convert.ToInt32(_Id), _userName);
            }

            txtTitle.Text = $"Re : {model.Title}";
            //string content = $"<br /><br />On {model.PostDate}, '{model.Name}' wrote:<hr />{model.Content}";
            string content = $"\r\n\r\nOn {model.PostDate}, '{model.Name}' wrote:\r\n{model.Content}";

            txtContent.Text = content;
        }
 // 특정 사용자의 전체 리스트(페이징 처리)
 public List <Support> GetSupports(int startIndex, int maxRows)
 {
     using (var db = new SupportContext())
     {
         string userName = HttpContext.Current.Session["UserName"].ToString();
         if (AccountHandler.HasGroup("Administrators"))
         {
             return(db.Supports
                    .OrderByDescending(s => s.Ref)
                    .ThenBy(s => s.RefOrder)
                    .Skip(startIndex)
                    .Take(maxRows).ToList());
         }
         else
         {
             return(db.Supports
                    .Where(s => s.UserName == userName)
                    .OrderByDescending(s => s.Ref)
                    .ThenBy(s => s.RefOrder)
                    .Skip(startIndex)
                    .Take(maxRows).ToList());
         }
     }
 }