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(); }
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(); }