public IActionResult Delete(ProductCategoriesModel m)
        {
            _applicationDbContext.ProductCategories.Remove(m);
            _applicationDbContext.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        private void SaveCategory()
        {
            var category = new ProductCategoriesModel {
                ProductCategoryName = mEtCategory.Text.ToUpper().Trim(),
                Rank = mCategoriesDataAccess.GetMaxRank() + 1
            };

            mCategoriesDataAccess.InsertIntoTable(category);
        }
        public ActionResult ProductCategories(ProductCategoriesModel model)
        {
            this.ServiceResponse = services.GetProductCategoryList(this.CurrentUser, model.ProductFamilyId);

            ProcessServiceResponse(this.ServiceResponse);

            this.RouteData.Values["action"] = "ProductCategories";

            return((IsPostRequest) ? (ViewResultBase)PartialView("ProductCategories", this.ServiceResponse.Model) : (ViewResultBase)View("ProductCategories", this.ServiceResponse.Model));
        }
Esempio n. 4
0
        private void UpdateCategory()
        {
            var category = new ProductCategoriesModel
            {
                ProductCategoryName = mEtCategory.Text.ToUpper().Trim(),
                Id = selectedCategory.Id
            };

            mCategoriesDataAccess.UpdateTable(category);
        }
Esempio n. 5
0
 public CategoriesDataAccess()
 {
     CreateTable();
     //insert "All" Category as Id 1
     if (!NameExists("All"))
     {
         var Category = new ProductCategoriesModel {
             ProductCategoryName = "All",
             Rank = 1
         };
         InsertIntoTable(Category);
     }
 }
Esempio n. 6
0
 public bool InsertIntoTable(ProductCategoriesModel row)
 {
     try
     {
         using (var connection = new SQLiteConnection(connectionString))
         {
             connection.Insert(row);
             return(true);
         }
     }
     catch (SQLiteException ex)
     {
         Log.Info("SQLiteEx", ex.Message);
         return(false);
     }
 }
Esempio n. 7
0
 public bool UpdateTable(ProductCategoriesModel ProductCategoriesModel)
 {
     try
     {
         using (var connection = new SQLiteConnection(connectionString))
         {
             connection.Query <ProductCategoriesModel>("UPDATE ProductCategoriesModel set ProductCategoryName=? Where Id=?",
                                                       ProductCategoriesModel.ProductCategoryName, ProductCategoriesModel.Id);
             return(true);
         }
     }
     catch (SQLiteException ex)
     {
         Log.Info("SQLiteEx", ex.Message);
         return(false);
     }
 }
Esempio n. 8
0
 private void FnGetData()
 {
     isSize                = Intent.GetBooleanExtra("isSize", false);
     isEdit                = Intent.GetBooleanExtra("isEdit", false);
     selectedRecordId      = Intent.GetIntExtra("selectedRecordId", 0);
     mSizesDataAccess      = new SizesDataAccess();
     mCategoriesDataAccess = new CategoriesDataAccess();
     if (isEdit)
     {
         if (isSize)
         {
             selectedSize = mSizesDataAccess.SelectRecord(selectedRecordId)[0];
         }
         else
         {
             selectedCategory = mCategoriesDataAccess.SelectRecord(selectedRecordId)[0];
         }
     }
 }
        public IActionResult Delete(long Id)
        {
            ProductCategoriesModel prdtct = _applicationDbContext.ProductCategories.FirstOrDefault(o => o.Id == Id);

            return(View(prdtct));
        }
Esempio n. 10
0
        /// <summary>
        /// get the product categories
        /// </summary>
        /// <returns></returns>
        public ActionResult GetProductCategories()
        {
            // create the default model
            var model = new ProductCategoriesModel();

            //get the feature products to display
            var productCategories = _homePage.Descendants().Where(page => page.ContentType.Alias == "productCategoryPage" &&
                                                                  !page.Value <bool>("hideFromMenu") &&
                                                                  page.IsPublished())
                                    .ToList();

            //add each category to the model
            if (productCategories.Any())
            {
                foreach (var productCategory in productCategories)
                {
                    //set the default category page title
                    var categoryTitle = productCategory.Name;
                    //check if we have the page title set on the current page
                    if (productCategory.HasProperty("pageTitle") && productCategory.HasValue("pageTitle"))
                    {
                        // set the page title to override the default
                        categoryTitle = productCategory.GetProperty("pageTitle").Value().ToString();
                    }

                    //create the default category model
                    var categoryModel = new ProductCategory
                    {
                        CategoryLinkTitle   = categoryTitle,
                        CategoryLinkUrl     = productCategory.Url,
                        ProductCategoryPage = productCategory
                    };

                    //get the products for each category to add to the model
                    var categoryProducts = productCategory.Children().Where(page => page.ContentType.Alias == "productPage" &&
                                                                            !page.Value <bool>("hideFromMenu") &&
                                                                            page.IsPublished())
                                           .ToList();

                    //if we have some products, take 4 random ones
                    if (categoryProducts.Any())
                    {
                        var r             = new Random();
                        var modelProducts = categoryProducts.OrderBy(x => r.Next()).Take(4).ToList();
                        //get the model for each of the products
                        foreach (var product in modelProducts)
                        {
                            var productModel = _productsService.GetProductModel(product);
                            //add it to the category model
                            categoryModel.CategoriesProducts.Add(productModel);
                        }
                    }

                    //add the category model to the view model
                    model.ProductCategories.Add(categoryModel);
                }
            }

            //return the view with the model
            return(View("/Views/Partials/Global/ProductCategories.cshtml", model));
        }