Ejemplo n.º 1
0
        public Category UpsertCategory(Category category)
        {
            if(category.CategoryID == 0){

               return Execute<Category>(() =>
               {
                   category.CategoryID =
                       conn.Execute(@"INSERT category (Title, AccountID, ParentCategoryID)
                                      VALUES (@title, @accountID, @parentCategoryID); SELECT SCOPE_IDENTITY();",
                                      new { title = category.Title, parentCategoryID = category.ParentCategoryID, accountID = category.AccountID });
                   return category;
               });
               }else{
               conn.Execute(@"UPDATE category  set Title=@title, AccountID=@accountID, ParentCategoryID=@parentCategoryID
                               WHERE categoryID=@categoryID",
                                new { category.CategoryID, category.Title, category.ParentCategoryID, category.AccountID });
               return category;
               }
        }
Ejemplo n.º 2
0
 public Category Update(Category Category)
 {
     return categoryRepository.UpsertCategory(Category);
 }
Ejemplo n.º 3
0
        public Category SaveNew(Category Category)
        {
            Category.AccountID = getAccountID();

            return categoryRepository.UpsertCategory(Category);
        }