Esempio n. 1
0
        public static int CreateCategory(string categoryName)
        {
            ProductCategoryModel data = new ProductCategoryModel
            {
                CategoryName = categoryName
            };

            string sql = @"insert into dbo.Category(CategoryName) values (@CategoryName); SELECT CAST(SCOPE_IDENTITY() as int)";

            return(SqlDataAccess.SaveDataGiveID(sql, data));
        }
Esempio n. 2
0
        public static int CreateProduct(string productName, int categoryId, string description, int price, DateTime date, string urlLink)
        {
            ProductModel data = new ProductModel
            {
                ProductName  = productName,
                CategoryId   = categoryId,
                Description  = description,
                ProductPrice = price,
                Date         = date,
                UrlLink      = urlLink
            };

            string sql = @"insert into dbo.Products(ProductName, CategoryId, Description, ProductPrice, Published, UrlLink)
                            values (@ProductName, @CategoryId, @Description, @ProductPrice, @Date, @UrlLink); SELECT CAST(SCOPE_IDENTITY() as int)";

            return(SqlDataAccess.SaveDataGiveID(sql, data));
        }