public async Task <IActionResult> Review(String reviewText, String userName, int productId, int productRating) { using (var context = new TackleHackSQLContext()) { var review = new Review() { Text = reviewText, UserName = userName, DateTime = DateTime.Now, Rating = productRating }; context.Add(review); await context.SaveChangesAsync(); var productReview = new ProductReview() { ReviewId = review.Id, ProductId = productId }; context.Add(productReview); await context.SaveChangesAsync(); return(RedirectToAction("Details", new { id = productId })); } }
public async Task <IActionResult> Create([Bind("Id,Name,Phone,Email")] Vendor vendor) { if (ModelState.IsValid) { using (var context = new TackleHackSQLContext()) { context.Add(vendor); await context.SaveChangesAsync(); var membership = new Membership() { AccountId = 1, VendorId = vendor.Id, UserName = User.Identity.Name }; context.Add(membership); await context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } return(View(vendor)); }
public async Task <IActionResult> Create([Bind("Id,ItemNumber,BrandName,ProductName,Description,Sku,Msrp,VendorId")] Product product) { using (var context = new TackleHackSQLContext()) { if (ModelState.IsValid) { context.Add(product); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["VendorId"] = new SelectList(await context.Vendor.ToListAsync(), "Id", "Name", product.VendorId); return(View(product)); } }
public async Task <IActionResult> AddToCart(String userName, int productId) { using (var context = new TackleHackSQLContext()) { var cart = new Cart() { UserName = userName, DateTime = DateTime.Now, ProductId = productId, Quantity = 1, Status = 0 }; context.Add(cart); await context.SaveChangesAsync(); return(RedirectToAction("Details", new { id = productId })); } }