public bool AddCategory(Category category) { var idParam = new SqlParameter { ParameterName = "categoryName", Value = category.CategoryName }; try { _dc.Database.ExecuteSqlCommand( "INSERT INTO Categories (CategoryName) VALUES (@CategoryName)", idParam ); } catch (Exception) { return false; } return true; }
public bool UpdateCategory(Category category) { var idParam = new SqlParameter { ParameterName = "CategoryName", Value = category.CategoryName }; var idParam1 = new SqlParameter { ParameterName = "CategoryID", Value = category.CategoryID }; try { _dc.Database.ExecuteSqlCommand( "UPDATE Categories SET CategoryName = @CategoryName WHERE CategoryID = @CategoryID", idParam, idParam1 ); } catch (Exception) { return false; } return true; }