8. Models 폴더의 DotNetNote 폴더에 INoteRepository.cs 파일을 생성하고, 다음과 같이 코드를 작성한다. Notes 테이블의 CRUD를 구현하는 규약을 정의한 INoteRepository 인터페이스의 내용이다. 리파지터리 클래스에서 사용할 각각의 메서드에 대한 시그니처를 담고 있다.

    ▼  /Models/DotNetNote/INoteRepository.cs

    using System.Collections.Generic;
    
    namespace DotNetNote.Models
    {
      public interface INoteRepository
      {
          // 게시판에서 사용
          void Add(Note model);
          int DeleteNote(int id, string password);
          List<Note> GetAll(int page);
          int GetCountAll();
          int GetCountBySearch(string searchField, string searchQuery);
          string GetFileNameById(int id);
          Note GetNoteById(int id);
          List<Note> GetSeachAll(
              int page, string searchField, string searchQuery);
          void ReplyNote(Note model);
          void UpdateDownCount(string fileName);
          void UpdateDownCountById(int id);
          int UpdateNote(Note model);
          
          // 메인 페이지에서 사용
          List<Note> GetRecentPosts();
          List<Note> GetNewPhotos();
          List<Note> GetNoteSummaryByCategory(string category);
          
          // 관리자 기능(페이지)에서 사용
          void Pinned(int id);
      }
    }
    

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.