public void A_CreateCategory()
        {
            Category category = new Category("testName");

            IRepository<Category> categoryRep = new CategoryRepository();
            categoryRep.Create(category);
        }
Пример #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 Delete(Category entity)
 {
     using (var session = NHibernateHelper.OpenSession())
     {
         using (ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.Delete(entity);
                 transaction.Commit();
             }
             catch (ADOException)
             {
                 throw new Exception("Defined category doesn't exist");
             }
         }
     }
 }
 public void Update(Category 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 category");
             }
         }
     }
 }
 public void Create(Category entity)
 {
     using (var session = NHibernateHelper.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             try
             {
                 session.Save(entity);
                 transaction.Commit();
             }
             catch (NHibernate.ADOException)
             {
                 throw new Exception("Defined category already exists");
             }
         }
     }
 }