コード例 #1
0
 public static AuthorDto CreateAuthor(AuthorDto authorDto)
 {
     using (var uow = new UnitOfWork())
     {
         ENTAuthor nTAuthors = uow.AuthorRepository.GetByName(authorDto.Name);
         if (nTAuthors == null)// yazar yoksa
         {
             ENTAuthor entAuthor = new ENTAuthor();
             entAuthor.Name = authorDto.Name;
             uow.AuthorRepository.Add(entAuthor);
             authorDto.ID = entAuthor.ID;
             if (entAuthor != null)
             {
                 AuthorDto newAuthor = new AuthorDto()
                 {
                     ID   = entAuthor.ID,
                     Name = entAuthor.Name
                 };
                 return(newAuthor);
             }
             return(null);
         }
         else
         {
             AuthorDto author = new AuthorDto()
             {
                 ID   = nTAuthors.ID,
                 Name = nTAuthors.Name,
             };
             return(null);
         }
     }
 }
コード例 #2
0
 public static AuthorDto GetAuthorByID(int ID)
 {
     using (var uow = new UnitOfWork())
     {
         ENTAuthor nTAuthors = uow.AuthorRepository.GetByID(ID);
         AuthorDto author    = new AuthorDto();
         author.ID   = nTAuthors.ID;
         author.Name = nTAuthors.Name;
         return(author);
     }
 }
コード例 #3
0
 public static AuthorDto GetAuthorByName(string name)
 {
     using (var uow = new UnitOfWork())
     {
         ENTAuthor nTAuthors = uow.AuthorRepository.GetByName(name);
         if (nTAuthors == null)
         {
             return(null);
         }
         AuthorDto author = new AuthorDto()
         {
             ID   = nTAuthors.ID,
             Name = nTAuthors.Name
         };
         return(author);
     }
 }