public virtual CategoryItem Save(CategoryItem categoryItem) { if (categoryItem == null) { throw new ArgumentException("CategoryItem cannot be null"); } Category category = null; if (categoryItem.Id == 0) { category = categoryItem.CreateCategory(); } else { category = this.categoryManager.Get(categoryItem.Id); categoryItem.UpdateCategory(category); } var categoryInDB = this.categoryManager.Save(category); var categoryItemToReturn = CategoryItem.FromModel(categoryInDB); return(categoryItemToReturn); }