public async Task <IActionResult> Detail(int?id) { if (id == null) { return(NotFound()); } Product singlePro = _context.Products.Include("ProductPictures.Picture").FirstOrDefault(p => p.ID == id); if (singlePro == null) { return(NotFound()); } ProductDetailVM vm = new ProductDetailVM(); vm.Product = singlePro; vm.FeaturedProducts = _context.Products.Include("ProductPictures.Picture") .Where(x => x.IsFeatured).ToList(); vm.SameCategoryPro = await _context.Products.Include("ProductPictures.Picture") .Where(x => x.CategoryID == singlePro.CategoryID && x.ID != singlePro.ID) .Take(3) .ToListAsync(); return(View(vm)); }
// GET: Product/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Product product = db.Products.Find(id); if (product == null) { return(HttpNotFound()); } List <Image> images = db.Images.Where(i => i.ProductId == product.ProductId).ToList(); var productDetail = new ProductDetailVM { ProductId = product.ProductId, Images = images, ProductName = product.ProductName, ProductSummary = product.ProductSummary, ProductSpecification = product.ProductSpecification, Price = product.Price, Quantity = product.Quantity }; return(View(productDetail)); }
public async Task <ActionResult> ProductSummary(int inp) { ProductDetailVM pObj = new ProductDetailVM(); string apiRegister = "http://localhost:57022/WebAPI/getProductPageValues?productID="; apiRegister += inp; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(apiRegister); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(apiRegister); //if (response.IsSuccessStatusCode) string data = (await response.Content.ReadAsStringAsync()); if (data == null) { return(View("ProductSummary")); } else { char[] delimiterChars = { ',' }; string[] words = data.Split(delimiterChars); pObj.data = words; return(View("ProductSummary", pObj)); } }
public async Task <IActionResult> Details(int id) { var ProductDetailVM = new ProductDetailVM(); ProductDetailVM.Product = await _db.Products.Include(m => m.Categories).Include(m => m.SpecialTags).Where(m => m.Id == id).FirstOrDefaultAsync(); ProductDetailVM.Reviews = await _db.Reviews.Where(x => x.ProductId == id).ToListAsync(); return(View(ProductDetailVM)); }
public async Task <ProductDetailVM> GetProductVMById(Guid id, Guid colorId) { if (id == Guid.Empty) { ProductDetailVM productDetail = new ProductDetailVM(); return(productDetail); } return(await productVMRepository.GetProductVMById(id, colorId)); }
// GET: ProductDetail public ActionResult Index(int prcID) { TREKKINGDBEntities db = new TREKKINGDBEntities(); ProductDetailVM prcVM = new ProductDetailVM(); ProductList prc = new ProductList(); prcVM.ProductDt = prc.mtdProductDt(prcID); prcVM.Sizes = prc.mtdProductDtSize(prcID); prcVM.KategoriBirListe = prc.KatBirListe(); prcVM.KategoriIkiListe = prc.KatIkiListe(); return(View(prcVM)); }
public ProductDetailPage(string productId) { InitializeComponent(); //InitProductDetailPageAsync(productId); //productDetailVM.product = productInfo; productDetailVM = new ProductDetailVM(productId); //var htmlSource = new HtmlWebViewSource(); //htmlSource.Html = @"<html><body>" + productDetailVM.Product.detail + "</body></html>"; //webView.Source = htmlSource; BindingContext = productDetailVM; }
public IActionResult Update(int id, ProductDetailVM productDetailVM) { if (id != productDetailVM.Id) { return(BadRequest()); } var result = _productSer.Update(id, productDetailVM); if (!result) { return(NotFound()); } return(NoContent()); }
public ActionResult <ProductDetailVM> Create(ProductDetailVM productDetailVM) { if (!ModelState.IsValid) { return(BadRequest()); } var result = _productSer.Add(productDetailVM); if (result == null) { return(Problem("Can't add new product")); } return(CreatedAtAction(nameof(Get), new { id = result.Id }, result)); }
public async Task <IActionResult> Review(Reviews review) { if (ModelState.IsValid) { _db.Add(review); await _db.SaveChangesAsync(); } var ProductDetailVM = new ProductDetailVM(); ProductDetailVM.Product = await _db.Products.Include(m => m.Categories).Include(m => m.SpecialTags).Where(m => m.Id == review.ProductId).FirstOrDefaultAsync(); ProductDetailVM.Reviews = await _db.Reviews.Where(x => x.ProductId == review.ProductId).ToListAsync(); return(View("Details", ProductDetailVM)); }
public ActionResult NewProductDetails(int?id) { Session["detailVM"] = null; ProductDetailVM detailVM = new ProductDetailVM(); if (id > 0) { Product product = _productRepository.Products.FirstOrDefault(p => p.ProductID == id); detailVM = new ProductDetailVM(); detailVM.SelectedProduct = product; detailVM.RelatedProducts = _productRepository.Products.Where(p => p.CategoryId == product.CategoryId).OrderBy(p => p.ProductID).Take(6).ToList(); detailVM.CategoryName = _productRepository.Categories.FirstOrDefault(c => c.Id == product.CategoryId).Name; detailVM.NewProducts = _productRepository.Products.OrderByDescending(p => p.ProductID).Take(4).ToList(); detailVM.HasEmptyRelatedProducts = true; Session["detailVM"] = detailVM; } return(PartialView("~/Views/Product/_productDetails.cshtml", detailVM)); }
public async Task <ActionResult> GetProductDetails(string ProductIDList) { string apiUrl_User = "******"; apiUrl_User += "UserID=" + Session["UserID"].ToString(); HttpClient client = new HttpClient(); client.BaseAddress = new Uri(apiUrl_User); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(apiUrl_User); var data_user = await response.Content.ReadAsStringAsync(); UserModel User = JsonConvert.DeserializeObject <UserModel>(data_user); string apiUrl = "http://localhost:57022/WebAPI/GetProductListForCompare?"; foreach (string i in ProductIDList.Split(',')) { apiUrl += "ProductIDList=" + i + "&"; } client = new HttpClient(); client.BaseAddress = new Uri(apiUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); response = await client.GetAsync(apiUrl); var data = await response.Content.ReadAsStringAsync(); List <ProductDetails> ldd = JsonConvert.DeserializeObject <List <ProductDetails> >(data); ProductDetailVM ProductList = new ProductDetailVM(); ProductList.ProductList = ldd; ProductList.User = User; return(View("ProductCompare", ProductList)); }
public IActionResult Detail(int?id) { if (id == null) { return(NotFound()); } ProductDetailVM pvm = new ProductDetailVM(); var dbProduct = _db.Products.Where(p => p.Id == id).AsNoTracking().FirstOrDefault(); if (dbProduct != null) { pvm.Product = dbProduct; return(View("Detail", pvm)); } return(NotFound()); }
public ActionResult ProductDetails(int?id) { id = id < 0 ? 1 : id; ProductDetailVM detailVM = new ProductDetailVM(); detailVM = (ProductDetailVM)Session["detailVM"]; Product product = _productRepository.Products.FirstOrDefault(p => p.ProductID == id); if (detailVM == null) { if (product != null) { detailVM = new ProductDetailVM(); detailVM.SelectedProduct = product; detailVM.RelatedProducts = _productRepository.Products.Where(p => p.CategoryId == product.CategoryId).OrderBy(p => p.ProductID).Take(6).ToList(); detailVM.CategoryName = _productRepository.Categories.FirstOrDefault(c => c.Id == product.CategoryId).Name; detailVM.NewProducts = _productRepository.Products.OrderByDescending(p => p.ProductID).Take(4).ToList(); detailVM.HasEmptyRelatedProducts = true; } Session["detailVM"] = detailVM; } else { detailVM = (ProductDetailVM)Session["detailVM"]; var moreRelatedProducts = _productRepository.Products.Where(p => p.CategoryId == detailVM.SelectedProduct.CategoryId && p.ProductID > id) .OrderBy(p => p.ProductID).Take(6).ToList(); if (moreRelatedProducts.Count > 0) { detailVM.RelatedProducts = moreRelatedProducts; detailVM.HasEmptyRelatedProducts = true; } else { detailVM.RelatedProducts = _productRepository.Products.Where(p => p.CategoryId == product.CategoryId).OrderBy(p => p.ProductID).Take(6).ToList(); detailVM.HasEmptyRelatedProducts = false; } Session["detailVM"] = detailVM; } return(PartialView("~/Views/Product/_productDetails.cshtml", detailVM)); }
// GET: Products public ActionResult Details(int?id) { if (id == null) { return(HttpNotFound()); } Product product = _context.Products.Find(id); if (product == null) { return(HttpNotFound()); } var vm = new ProductDetailVM { Product = product, RelatedProducts = _context.Products.Where(c => c.CategoryId == product.CategoryId) }; return(View(vm)); }
public async Task <ProductDetailVM> GetProductVMById(Guid id, Guid colorId) { ProductDetailVM product = new ProductDetailVM(); if (colorId != Guid.Empty) { product = await ctx.ProductColor.Where(p => p.ProductId == id && p.ColorId == colorId) .Select(p => new ProductDetailVM { ProductId = p.Product.ProductId, Name = p.Product.Name, Price = p.Product.Price, Discount = p.Product.Discount, ImageUrl = p.ImageUrl, Detail = p.Product.Detail, BrandName = p.Product.Brand.Name }) .FirstOrDefaultAsync(); } else { product = await ctx.ProductColor.Where(p => p.ProductId == id) .Select(p => new ProductDetailVM { ProductId = p.Product.ProductId, Name = p.Product.Name, Price = p.Product.Price, Discount = p.Product.Discount, ImageUrl = p.ImageUrl, Detail = p.Product.Detail, BrandName = p.Product.Brand.Name }) .FirstOrDefaultAsync(); } //IList<string> product = await ctx.ProductColor.Where(s => s.ProductId == id).Select(s => s.ImageUrl).ToListAsync(); //return product; return(product); }
public ProductDetailPage(string productId) { InitializeComponent(); BindingContext = new ProductDetailVM(productId); }
public ActionResult Edit(ProductDetailVM model) { _productDetailService.Update(model); return(RedirectToAction("Index")); }
public ActionResult Create(ProductDetailVM model) { _productDetailService.Insert(model); return(RedirectToAction("Index")); }
public void Update(ProductDetailVM model) { _productDetailRepository.Update(ProjectMapper.ConvertToEntity <ProductDetail>(model)); }