public ActionResult Edit(long?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var entity = Dao.Detail(Id); if (entity == null) { return(HttpNotFound()); } var output = new CategoryProductsModel(); output.Date = entity.Date; output.Id = entity.Id; output.Meta_Description = entity.Meta_Description; output.Meta_Keyword = entity.Meta_Keyword; output.Meta_Title = entity.Meta_Title; output.Modified = entity.Modified; output.Name = entity.Name; output.Order = entity.Order; output.ParentId = entity.ParentId; output.Slug = entity.Slug; output.Status = entity.Status; output.Taxonomy = entity.Taxonomy; output.Thumbnail = entity.Thumbnail; output.Title = entity.Title; output.UserId = entity.UserId; ViewBag.ParentId = new SelectList(Dao.ListAllByTaxonomy("Product"), "Id", "Name", output.ParentId); return(View(output)); }
public ActionResult Add(CategoryProductsModel input) { if (ModelState.IsValid) { input.UserId = SessionHelper.GetSessionUser().UserId; input.Taxonomy = input.Taxonomy ?? "Product"; input.Status = input.Status ?? true; input.Order = input.Order ?? 0; input.Date = input.Date ?? DateTime.Now; input.Modified = input.Modified ?? DateTime.Now; var entity = new tb_Catogory(); entity.Date = input.Date; entity.Meta_Description = input.Meta_Description; entity.Meta_Keyword = input.Meta_Keyword; entity.Meta_Title = input.Meta_Title; entity.Modified = input.Modified; entity.Name = input.Name; entity.Order = input.Order; entity.ParentId = input.ParentId; entity.Slug = input.Slug; entity.Status = input.Status; entity.Taxonomy = input.Taxonomy; entity.Thumbnail = input.Thumbnail; entity.Title = input.Title; entity.UserId = input.UserId; long Id = Dao.Insert(entity); return(RedirectToAction("Edit", "CategoryProducts", new { Id = Id })); } ViewBag.ParentId = new SelectList(Dao.ListAllByTaxonomy("Product"), "Id", "Name", input.ParentId); return(View(input)); }
public ActionResult Edit(CategoryProductsModel entity) { if (ModelState.IsValid) { entity.UserId = SessionHelper.GetSessionUser().UserId; entity.Taxonomy = entity.Taxonomy ?? "Product"; entity.Status = entity.Status ?? true; entity.Order = entity.Order ?? 0; entity.Date = entity.Date ?? DateTime.Now; entity.Modified = entity.Modified ?? DateTime.Now; var input = new tb_Catogory(); input.Date = entity.Date; input.Id = entity.Id; input.Meta_Description = entity.Meta_Description; input.Meta_Keyword = entity.Meta_Keyword; input.Meta_Title = entity.Meta_Title; input.Modified = entity.Modified; input.Name = entity.Name; input.Order = entity.Order; input.ParentId = entity.ParentId; input.Slug = entity.Slug; input.Status = entity.Status; input.Taxonomy = entity.Taxonomy; input.Thumbnail = entity.Thumbnail; input.Title = entity.Title; input.UserId = entity.UserId; Dao.Update(input); } ViewBag.ParentId = new SelectList(Dao.ListAllByTaxonomy("Product"), "Id", "Name", entity.ParentId); return(View(entity)); }
public IActionResult CategoryProducts(string category, string subCategory) { var categoryId = catService.GetCategoryId(category); if (categoryId == null) { return(RedirectToAction("NotFoundPage")); } var subCategoryId = catService.GetCategoryId(subCategory); var homeCatalogModel = new CategoryProductsModel(); var categoriesId = new List <int>(); if (subCategoryId != null) { categoriesId.Add((int)subCategoryId); homeCatalogModel.CurrentCategory = subCategory; } else { categoriesId = catService.GetAllRelatedCategoriesIds((int)categoryId); homeCatalogModel.CurrentCategory = category; } homeCatalogModel.Products = prodService.GetProductsByCategoriesId(categoriesId); homeCatalogModel.Categories = catService.GetAllCategoryModels(); return(View(homeCatalogModel)); }
public ActionResult Category(long?id) { if (id == null) { return(View("NotFound")); } CategoryProductsModel categoryProducts = new CategoryProductsModel { Categories = db.ProductCategories.Where(e => e.Category == id).ToList().AsEnumerable(), Products = db.Products.Where(e => e.Category == id).ToList().AsEnumerable() }; return(View(categoryProducts)); }
public ActionResult Search(string search, long page = 0, int capacity = 20) { if (Request.Cookies["Currency"] == null) { InitializeCurrency(); } if (search == null) { search = ""; } var products = CategoryProductDAO.FindProducts(search, Request.Cookies["Currency"]); CategoryProductsModel categoryProducts = new CategoryProductsModel { Products = products.Skip(capacity * (int)page).Take(capacity), Search = search, Page = page, Pages = (products.Count() - 1) / capacity, }; ViewData["Search"] = search; return(View(categoryProducts)); }
public ActionResult Category(long?id, long page = 0, int capacity = 20) { if (Request.Cookies["Currency"] == null) { InitializeCurrency(); } if (id == null) { return(View("NotFound")); } var products = CategoryProductDAO.SelectProductsByHierarchy(ProductCategoryDAO.Select(id).Id.Value, Request.Cookies["Currency"]); var categories = ProductCategoryDAO.SelectItemsByCategory(id).AsEnumerable(); CategoryProductsModel categoryProducts = new CategoryProductsModel { Categories = categories, Products = products.Skip(capacity * (int)page).Take(capacity), Page = page, Pages = (products.Count() - 1) / capacity, Category = ProductCategoryDAO.Select(id) }; return(View(categoryProducts)); }