예제 #1
0
        public void EditSubCategory(SubCategory item, MainCategory m_cat)
        {
            var newSubCategory = new DbSubCategory()
            {
                Name = item.Name,
                Category = Db.MainCategorys.GetItem(m_cat.ID),
                CategoryID = m_cat.ID
            };

            Db.MainCategorys.Update(Db.MainCategorys.GetItem(item.CategoryID));
            Db.SubCategorys.Update(newSubCategory);
            Db.Save();
        }
예제 #2
0
        public void CreateSubCategory(SubCategory item, MainCategory m_cat)
        {
            MainCategory category = Mapper.Map<DbMainCategory, MainCategory>(Db.MainCategorys.GetItem(m_cat.ID));
            var newSubCat = new DbSubCategory()
            {
                Name = item.Name,
                Category = Db.MainCategorys.GetItem(m_cat.ID),
                CategoryID = m_cat.ID
            };

            Db.SubCategorys.Create(newSubCat);
            category.SubCategorys.Add(item);
            Db.SubCategorys.Update(newSubCat);
            Db.Save();
        }