public void A_CreateAuthor()
        {
            Author author = new Author("testname", "testName");

            IRepository<Author> authorRep = new AuthorRepository();
            authorRep.Create(author);
        }
Exemple #2
0
 public Article(string titleHr, string titleEng, string contentHr, string contentEng, string summaryHr, string summaryEng, string youTubeCode, bool publicContent, bool onEnglish, bool hasVideo, Category category, Author author, List<Photo> photos)
 {
     TitleHr = titleHr;
     TitleEng = titleEng;
     ContentHr = contentHr;
     ContentEng = contentEng;
     SummaryHr = summaryHr;
     SummaryEng = summaryEng;
     YouTubeCode = youTubeCode;
     PublicContent = publicContent;
     OnEnglish = onEnglish;
     HasVideo = hasVideo;
     Category = category;
     Author = author;
     CreationDate = DateTime.Now;
     Photos = photos;
 }
 public void Update(Author entity)
 {
     using (var session = NHibernateHelper.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             try
             {
                 session.Update(entity);
                 transaction.Commit();
             }
             catch (ADOException)
             {
                 throw new Exception("Unable to update author");
             }
         }
     }
 }
 public void Delete(Author entity)
 {
     using (var session = NHibernateHelper.OpenSession())
     {
         using (ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.Delete(entity);
                 transaction.Commit();
             }
             catch (ADOException)
             {
                 throw new Exception("Defined author doesn't exist");
             }
         }
     }
 }
 public void Create(Author entity)
 {
     using (var session = NHibernateHelper.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             try
             {
                 session.Save(entity);
                 transaction.Commit();
             }
             catch (NHibernate.ADOException)
             {
                 throw new Exception("Defined author already exists");
             }
         }
     }
 }