Beispiel #1
0
 public Board GetBoard(int boardNo) //1개의 게시글을 받아온다
 {
     using (var db = new NoteDbContext(_configuration))
     {
         return(db.Boards.FirstOrDefault(b => b.No == boardNo));
     }
 }
Beispiel #2
0
 public List <Board> GetList()
 {
     using (var db = new NoteDbContext(_configuration))
     {
         return(db.Boards.OrderByDescending(b => b.No).ToList());
     }
 }
Beispiel #3
0
        public IOrderedQueryable <Board> GetBoardTracking() //페이징시 사용
        {
            var db     = new NoteDbContext(_configuration);
            var _board = db.Boards.AsNoTracking().OrderByDescending(b => b.No);

            return(_board);
        }
Beispiel #4
0
        public IOrderedQueryable <Notice> GetNoticeTracking()
        {
            var db      = new NoteDbContext(_configuration);
            var _notice = db.Notices.AsNoTracking().OrderByDescending(n => n.No);

            return(_notice);
        }
Beispiel #5
0
 public User GetUser(string id)
 {
     using (var db = new NoteDbContext(_configuration))
     {
         var data = db.Users.FirstOrDefault(u => u.UserId == id);
         return(data);
     }
 }
Beispiel #6
0
 /// <summary>
 /// 공지사항 상세 출력
 /// </summary>
 public Notice GetNotice(int noticeNo)
 {
     using (var db = new NoteDbContext(_configuration))
     {
         var notice = db.Notices.FirstOrDefault(n => n.No.Equals(noticeNo));
         return(notice);
     }
 }
Beispiel #7
0
 /// <summary>
 /// 공지사항 리스트 출력
 /// </summary>
 /// <returns></returns>
 public List <Notice> GetList()
 {
     using (var db = new NoteDbContext(_configuration))
     {
         return(db.Notices
                .OrderByDescending(n => n.No)
                .ToList());
     }
 }
Beispiel #8
0
 /// <summary>
 /// 공지사항 등록
 /// </summary>
 public bool SaveNotice(Notice notice)
 {
     using (var db = new NoteDbContext(_configuration))
     {
         db.Notices.Add(notice);
         if (db.SaveChanges() >= 1)
         {
             return(true);
         }
         return(false);
     }
 }
Beispiel #9
0
        public bool SaveBoard(Board board)
        {
            using (var db = new NoteDbContext(_configuration))
            {
                db.Boards.Add(board);
                if (db.SaveChanges() >= 1)
                {
                    return(true);
                }

                return(false);
            }
        }
Beispiel #10
0
 public bool SaveUser(User model)
 {
     using (var db = new NoteDbContext(_configuration))
     {
         db.Users.Add(model);
         if (db.SaveChanges() >= 1)
         {
             return(true);
         }
         else
         {
             throw new ArgumentException();
         }
     }
 }
Beispiel #11
0
 public bool DeleteBoard(int boardNo)
 {
     using (var db = new NoteDbContext(_configuration))
     {
         db.Remove(GetBoard(boardNo));
         if (db.SaveChanges() >= 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Beispiel #12
0
        public User GetUser(LoginViewModel model)
        {
            using (var db = new NoteDbContext(_configuration))
            {
                var user = db.Users.FirstOrDefault(u => u.UserId.Equals(model.UserId) && u.Password.Equals(model.Password));

                if (user != null)
                {
                    return(user);
                }
                else
                {
                    return(null);
                }
            }
        }
Beispiel #13
0
        public List <User> GetNonActiveUser()
        {
            using (var db = new NoteDbContext(_configuration))
            {
                var data = (from user in db.Users
                            join boards in db.Boards
                            on user.UserId equals boards.UserId
                            where user.UserId == "ksg"
                            select new User {
                    UserId = user.UserId, Name = user.Name
                }
                            ).ToList();

                return(data);
            }
        }
Beispiel #14
0
        public bool DeleteNotice(int noticeNo)
        {
            using (var db = new NoteDbContext(_configuration))
            {
                var _noticeNo = db.Notices.First(n => n.No == noticeNo);
                db.Notices.Remove(_noticeNo);

                if (db.SaveChanges() >= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// 공지사항 수정
        /// </summary>
        public bool UpdateNotice(Notice notice)
        {
            using (var db = new NoteDbContext(_configuration))
            {
                var _notice = db.Notices.First(n => n.No == notice.No);
                _notice.Title   = notice.Title;
                _notice.Content = notice.Content;

                if (db.SaveChanges() >= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #16
0
        public bool UpdateBoard(Board board)
        {
            using (var db = new NoteDbContext(_configuration))
            {
                var _board = db.Boards.First(b => b.No == board.No);
                _board.Title   = board.Title;
                _board.Content = board.Content;

                if (db.SaveChanges() >= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #17
0
        public IOrderedQueryable <Board> GetBoardTracking(string searchName)
        {
            var db = new NoteDbContext(_configuration);

            return(db.Boards.AsNoTracking().Where(b => b.Title.Contains(searchName) || b.Content.Contains(searchName)).OrderByDescending(b => b.No));
        }
Beispiel #18
0
        public IOrderedQueryable <Notice> GetNoticeTracking(string searchName)
        {
            var db = new NoteDbContext(_configuration);

            return(db.Notices.AsNoTracking().Where(n => n.Title.Contains(searchName) || n.Content.Contains(searchName)).OrderByDescending(n => n.No));
        }