public Int32 SaveCategory(CategoryDTO category) { Int32 id; if (category.Id == 0) { id = _unitOfWork.CategoryRepository.Create(new Category() { Name = category.Name, Products = new List<Product>() }).Id; } else { var cat = _unitOfWork.CategoryRepository.Read().Where(x => x.Id == category.Id).FirstOrDefault(); cat.Name = category.Name; id = cat.Id; _unitOfWork.CategoryRepository.Update(cat); } _unitOfWork.SaveChanges(); return id; }
public Int32 SaveCategory(CategoryDTO userGroup) { return _categoryManager.SaveCategory(userGroup); }