示例#1
0
        public string ProductCategoryAjaxHandler(AjaxResponseVM ajaxResponseVM)
        {
            RetailRepository retailRepo = new RetailRepository();

            retailRepo.AddRemoveProductCategoryAssignments(ajaxResponseVM);

            return(" ProductID:" + ajaxResponseVM.ProductID + " CategoryID:" + ajaxResponseVM.CategoryID);
        }
示例#2
0
        public void AddRemoveProductCategoryAssignments(AjaxResponseVM ar)
        {
            string sql;

            if (ar.Action == "insert")
            {
                sql = @"INSERT INTO ProductCategory (ProductID, CategoryID) VALUES (@productID, @categoryID)";
            }
            else
            {
                sql = @"DELETE FROM ProductCategory WHERE ProductID = @productID AND CategoryID = @categoryID";
            }

            using (IDbConnection db = new SqlConnection(connection))
            {
                db.Execute(sql, new { productID = ar.ProductID, categoryID = ar.CategoryID });
            }
        }