Beispiel #1
0
        public ActionResult GetUserPermission(BoardUser bu)
        {
            supertalentoftheworld.Models.Board board = db.Board.Find(bu.board_idx);

            if (board.BD_writer == bu.id && board.BD_password == bu.pw)
            {
                return(RedirectToAction("BoardWrite", new { id = bu.board_idx }));
            }
            else
            {
                if (board.BoardMenu.BM_type == "Free")
                {
                    if (Session["boardauth"].ToString() == "Admin")
                    {
                        return(RedirectToAction("BoardWrite", new { id = bu.board_idx }));
                    }
                    else
                    {
                        return
                            (Content("<script>alert('Check ID or Password'); location.href='" + bu.redirect + "';</script>"));
                    }
                }
                else if (board.BoardMenu.BM_type == "Admin")
                {
                    return(RedirectToAction("BoardWrite", new { id = bu.board_idx }));
                }

                return(Content("<script>alert('Check ID or Password'); location.href='" + bu.redirect + "';</script>"));
            }
        }
Beispiel #2
0
        public ActionResult UpdateBoard(supertalentoftheworld.Models.Board board)
        {
            int cate = board.BD_BM_idx;
            //기존 파일 변동사항을 파악한다
            string oriFileIdxs = Request["oriFileIdx"];

            List <int> oriFileIdxList = oriFileIdxs != null?oriFileIdxs.Split(',').Select(Int32.Parse).ToList() : null;

            supertalentoftheworld.Models.Board oriBoard = db.Board.Find(board.BD_idx);

            //DB에 원래 있던 파일들
            IEnumerable <BoardFile> dbfiles = oriBoard.BoardFile.Where(a => a.BF_useable == 1);

            foreach (BoardFile dbfile in dbfiles)
            {
                //변경된 파일에도 포함되어 있으면 그대로 유지, 아니면 useable = 0으로 변경
                if (!oriFileIdxList.Contains(dbfile.BF_idx))
                {
                    dbfile.BF_useable = 0;
                }
            }

            // 새로 들어온 파일들 체크
            var           fm    = new FileManager();
            List <string> files = fm.FileUpload();

            foreach (string file in files)
            {
                var bf = new BoardFile();
                bf.BF_BD_idx  = board.BD_idx;
                bf.BF_name    = file;
                bf.BF_useable = 1;
                bf.BF_wdate   = DateTime.Now;

                db.BoardFile.Add(bf);
            }

            //게시판 내용들 업데이트
            board.BD_edate = DateTime.Now;

            supertalentoftheworld.Models.Board updateboard = db.Board.Find(board.BD_idx);

            updateboard.BD_BM_idx   = board.BD_BM_idx;
            updateboard.BD_title    = board.BD_title;
            updateboard.BD_writer   = User.Identity.Name;
            updateboard.BD_password = board.BD_password;
            updateboard.BD_content  = board.BD_content;
            updateboard.BD_edate    = DateTime.Now;


            db.SaveChanges();


            string returnUrl = "/board/board_list?cate=" + cate;

            return(Redirect(returnUrl));
        }
Beispiel #3
0
        public ActionResult DelBoard(int?idx, string cate)
        {
            if (idx == null)
            {
                return(HttpNotFound());
            }

            supertalentoftheworld.Models.Board board = db.Board.Find(idx);
            BoardMenu bm = board.BoardMenu;

            board.BD_useable = 0;
            db.SaveChanges();


            string BM_url = "/board/board_list?cate=" + cate;

            return(Content("<script>alert('OK'); location.href='" + BM_url + "';</script>"));
        }
Beispiel #4
0
        public ActionResult CreateBoard(supertalentoftheworld.Models.Board board)
        {
            int cate = board.BD_BM_idx;



            if (ModelState.IsValid)
            {
                board.BD_wdate   = DateTime.Now;
                board.BD_hit     = 0;
                board.BD_useable = 1;
                board.BD_writer  = User.Identity.Name;

                db.Board.Add(board);
            }

            var           fm    = new FileManager();
            List <string> files = fm.FileUpload();

            int BD_idx = db.Board.Any() ? db.Board.Max(a => a.BD_idx) + 1 : 1;

            foreach (string file in files)
            {
                var bf = new BoardFile();
                bf.BF_BD_idx  = BD_idx;
                bf.BF_name    = file;
                bf.BF_useable = 1;
                bf.BF_wdate   = DateTime.Now;


                db.BoardFile.Add(bf);
            }
            db.SaveChanges();


            string returnUrl = "/board/board_list?cate=" + cate;

            return(Redirect(returnUrl));


            //return Content("<script>location.href='"+ returnUrl + "';</script>");
        }
Beispiel #5
0
        public ActionResult BoardWrite(int?idx, int?cate)
        {
            var board = new supertalentoftheworld.Models.Board();
            int auth  = Convert.ToInt16(Request.Cookies["check_auth"].Value);
            //첫글 임시작성
            var bmtemp = new BoardMenu();

            bmtemp.BM_url   = "/Board/Index";
            board.BoardMenu = bmtemp;
            if (cate != null)
            {
                BoardMenu bm = db.BoardMenu.Find(cate);
                board.BD_BM_idx = bm.BM_idx;
                board.BoardMenu = bm;
            }


            if (idx != null)
            {
                //수정모드
                board = db.Board.Find(idx);
            }


            //회사별 데이터 드롭다운==============================================================================================================================================
            string web_department_id = Request.Cookies["web_department_id"].Value ?? "";
            var    category          =
                db.BoardMenu.Where(
                    a => a.BM_com == Comname && a.BM_type != "photo" && ((a.department_id == web_department_id || a.open_yn == "Y"))).Select(
                    a => new { a.BM_idx, a.BM_title });

            ViewBag.category = new SelectList(category.AsEnumerable(), "BM_idx", "BM_title", board.BD_BM_idx);
            //=====================================================================================================================================================================



            return(View(board));
        }
Beispiel #6
0
        public ActionResult BoardView(int?idx)
        {
            if (idx == null)
            {
                return(HttpNotFound());
            }
            else if (idx == 0)
            {
                //0번 게시글은 임시글로써, DB에 존재하지 않는 글임
                return(Content("<script>alert('사용할 수 없는 게시물입니다.');history.back();</script>"));
            }



            supertalentoftheworld.Models.Board data = db.Board.Find(idx);

            string file_bbs =
                (from a in db.BoardFile where a.BF_BD_idx == idx select a.department_id).FirstOrDefault() ?? "";

            ViewBag.file_dir = file_bbs;

            data.BD_hit += 1;
            db.SaveChanges();

            //TODO :: 코멘트, 파일 가져와야함 뷰단에서


            IQueryable <bbs_comment> _list = Enumerable.Empty <bbs_comment>().AsQueryable();

            _list = db.bbs_comment.Where(p => p.BD_idx == idx && p.use_yn == "Y").OrderByDescending(o => o.idx);

            ViewBag.댓글 = _list;



            return(View(data));
        }
Beispiel #7
0
        public ActionResult m_photo_action()
        {
            int    cate = 7;
            string web_department_id = Request.Cookies["web_department_id"].Value ?? "";
            string machine_id        = Request["machine_id"] ?? "";
            int    project_id        = 0;

            if (!string.IsNullOrEmpty(Request["project_id"]))
            {
                project_id = Convert.ToInt32((Request["project_id"]));
            }


            HttpRequest httpRequest = System.Web.HttpContext.Current.Request;

            int    file_count = httpRequest.Files.Count;
            string title      = Request["title"] ?? "";


            var           fm    = new FileManager();
            List <string> files = fm.PhotoFileUpload(web_department_id);


            int count = 0;

            foreach (string file in files)
            {
                #region 포토게시판 기록

                int BD_idx = db.Board.Any() ? db.Board.Max(a => a.BD_idx) + 1 : 1;

                var _insert = new supertalentoftheworld.Models.Board
                {
                    BD_BM_idx  = cate,
                    BD_title   = title,
                    BD_writer  = User.Identity.Name,
                    BD_hit     = 0,
                    BD_wdate   = DateTime.Now,
                    BD_useable = 1,
                    machine_id = machine_id,
                    project_id = project_id
                };
                db.Board.Add(_insert);
                db.SaveChanges(); // 실제로 저장

                #endregion

                var bf = new BoardFile();
                bf.BF_BD_idx     = BD_idx;
                bf.BF_name       = file;
                bf.BF_useable    = 1;
                bf.BF_wdate      = DateTime.Now;
                bf.BF_type       = "P";
                bf.BD_BM_idx     = cate;
                bf.department_id = web_department_id;
                bf.machine_id    = machine_id;
                bf.main_img      = "N";
                bf.project_id    = project_id;
                bf.user_id       = User.Identity.Name;
                bf.file_title    = title;


                db.BoardFile.Add(bf);


                count++;
            }
            db.SaveChanges();

            //


            string returnUrl = "/board/m_photo_list?cate=7";

            return(Redirect(returnUrl));


            //return Content("<script>location.href='"+ returnUrl + "';</script>");
        }
Beispiel #8
0
        public ActionResult Board_List(int?cate, int?page)
        {
            string web_company_id    = "";
            string web_department_id = "";
            int    auth = 0;

            #region 언어선택
            //언어 추가

            string _language = Request["language"] ?? "korea";

            var language = new HttpCookie("language");
            language.Value = _language;
            Response.Cookies.Add(language);
            #endregion


            string search_all_type = Request["search_all_type"] ?? "";
            string search_all      = Request["search_all"] ?? "";

            ViewBag.search_all_type = search_all_type;
            ViewBag.search_all      = search_all;

            int _cate = 0;

            if (cate == null)
            {
                _cate = (from a in db.BoardMenu where a.open_yn == "Y" select a.BM_idx).FirstOrDefault();
                cate  = _cate;
            }


            //var data = db.BoardMenu.Find(id);


            BoardMenu bm = db.BoardMenu.Find(cate);
            ViewBag.BoardMenu = bm;

            var _type = (from a in db.BoardMenu where a.BM_idx == cate select a).FirstOrDefault();

            if (_type != null)
            {
                ViewBag.타입 = _type.BM_type;
            }
            else
            {
                ViewBag.타입 = "normal";
            }



            ViewBag.기본게시글 = cate;
            ViewBag.타이틀   = _type.BM_title;

            var board = new supertalentoftheworld.Models.Board();


            if (auth >= 8)
            {
                //회사별 데이터 드롭다운==============================================================================================================================================
                var category =
                    db.BoardMenu.Where(
                        a =>
                        a.BM_com == web_company_id && a.BM_type != "photo" &&
                        ((a.department_id == web_department_id || a.open_yn == "Y"))).Select(
                        a => new { a.BM_idx, a.BM_title });
                ViewBag.category = new SelectList(category.AsEnumerable(), "BM_idx", "BM_title", board.BD_BM_idx);
                //=====================================================================================================================================================================
            }
            else
            {
                //회사별 데이터 드롭다운==============================================================================================================================================
                var category =
                    db.BoardMenu.Where(
                        a =>
                        a.BM_com == web_company_id && a.BM_type != "photo" &&
                        ((a.department_id == web_department_id || a.open_yn == "Y"))).Select(
                        a => new { a.BM_idx, a.BM_title });
                ViewBag.category = new SelectList(category.AsEnumerable(), "BM_idx", "BM_title", board.BD_BM_idx);
                //=====================================================================================================================================================================
            }


            if (bm == null)
            {
                var emptyboard = new List <supertalentoftheworld.Models.Board>();


                board.BD_idx    = 0;
                board.BD_title  = "There's no writing";
                board.BD_writer = "Helper";
                board.BD_wdate  = DateTime.Now;
                board.BoardMenu = bm;
                board.BD_BM_idx = 1;
                emptyboard.Add(board);
                return(View(emptyboard));
            }
            else
            {
                #region 일반게기판

                IEnumerable <supertalentoftheworld.Models.Board> data = bm.Board.Where(a => a.BD_useable == 1 && a.BoardMenu.BM_type != "photo");

                if (!string.IsNullOrEmpty(search_all))
                {
                    if (search_all_type == "1")
                    {
                        data = data.Where(p => p.BD_title.Contains(search_all) || p.BD_content.Contains(search_all));
                    }
                    if (search_all_type == "2")
                    {
                        data = data.Where(p => p.BD_title.Contains(search_all));
                    }
                    if (search_all_type == "3")
                    {
                        data = data.Where(p => p.BD_writer.StartsWith(search_all));
                    }
                }

                //페이징 처리
                var pg = new pagination();

                pg.totalcount     = data.Any() ? data.Count() : 1;
                pg.takecount      = 10;
                pg.skipcount      = page == null ? 0 : (int)page * pg.takecount;
                pg.totalpagecount = Math.Ceiling((double)pg.totalcount / pg.takecount);
                data = data.OrderByDescending(a => a.BD_idx).Skip(pg.skipcount).Take(pg.takecount);

                ViewBag.pagination = pg;

                List <supertalentoftheworld.Models.Board> boarddata = data.ToList();
                //게시글이 없을 경우
                if (boarddata.Count() == 0)
                {
                    board.BD_idx    = 0;
                    board.BD_title  = "There's no writing";
                    board.BD_writer = "Helper";
                    board.BD_wdate  = DateTime.Now;
                    board.BoardMenu = bm;
                    board.BD_BM_idx = bm.BM_idx;
                    boarddata.Add(board);
                }
                return(View(boarddata));

                #endregion
            }
        }