public async Task <IActionResult> OnGetAsync(int productId, int categoryId) { ConfigDetails = await _configDetailService.GetAllConfigDetailsByProductId(productId); ConfigCharts = await _configChartService.GetAllConfigChartByCategoryId(categoryId); ConfigGroups = await _configGroupService.GetAllConfigGroupByCategoryId(categoryId); Product = await _productService.GetProductById(productId); ViewData["CategoryId"] = categoryId; ViewData["ProductId"] = productId; foreach (var chart in ConfigCharts) { if (!_configDetailService.AnyConfigDetailsByProductIdAndConfigChartId(productId, chart.Id)) { var configDetail = new ConfigDetail() { ProductId = productId, ConfigGroupId = chart.ConfigGroupId, ConfigChart = chart, ConfigChartId = chart.Id, Value = null }; await _configDetailService.AddConfigDetail(configDetail); } } return(Page()); }
public async Task <Domain.Entities.Product.Product> AddAsync(Domain.Entities.Product.Product product) { _context.ChangeTracker.AutoDetectChangesEnabled = false; await _context.AddAsync(product); _cachingRepository.Cache(product.Id.ToString(), product); _context.ChangeTracker.AutoDetectChangesEnabled = true; return(product); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Product = await _context.Products.FindAsync(id); if (Product != null) { _context.Products.Remove(Product); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Product = await _context.Products .Include(p => p.Brand) .Include(p => p.Category).FirstOrDefaultAsync(m => m.ProductId == id); if (Product == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Product = await _productService.GetProductById(id); if (Product == null) { return(NotFound()); } ViewData["ProductImage"] = Product.Image ?? "no-image.png"; ViewData["BrandId"] = new SelectList(await _brandService.GetAllBrands(), "Id", "Name"); ViewData["CategoryId"] = new SelectList(await _categoryService.GetAllCategories(), "Id", "Name"); Product.MetaTitle = TextConvertor.ReplaceLetters(Product.MetaTitle, '-', ' '); return(Page()); }
public void Update(Domain.Entities.Product.Product product) { _context.Products.Update(product); _cachingRepository.Cache(product.Id.ToString(), product); }
public async Task OnGetAsync(int productId) { Product = await _productService.GetProductById(productId); Comment = await _commentService.GetAllCommentsByProductId(productId); }