public async Task <Order> AddOrderAsync(Order order) { _context.Orders.Add(order); await _context.SaveChangesAsync(); return(order); }
//public async Task<IActionResult> Create([Bind("CategoryId,Id,Name,Description,Price,IsTradable,CreatedAt,Images")] Product product,Image image) public async Task <IActionResult> Create([Bind("CategoryId,Id,Name,Description,Price,IsTradable,CreatedAt,Images")] Product product) { if (ModelState.IsValid) { if (product.Images == null) { product.Images = new List <ProductsImages>() { }; product.Images.Add(new ProductsImages() { ProdId = product.Id, ColorId = 1, ImgSrc = "Poster_not_available.jpg" }); } product.CreatedAt = DateTime.Now; _context.Add(product); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); var createdProd = _context.Product.LastOrDefault(); //return RedirectToAction("CreateSpesificQuantity", "ProductsQuantities", createdProd.Id); return(RedirectToAction("Create", "ProductsQuantities")); } return(View(product)); }
public async Task <Customer> AddCustomerAsync(Customer customer) { _context.Customers.Add(customer); await _context.SaveChangesAsync(); return(customer); }
public async Task <IActionResult> Create([Bind("Id,NickName,FirstName,LastName,UserType,PhoneNumber,Email,CreatedAt,UpdatedAt, Password")] User user) { if (ModelState.IsValid) { user.UserType = UserType.Customer; user.CreatedAt = DateTime.Now; _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create([Bind("ProdId,SizeId,ColorId,Quantity")] ProductsQuantity productsQuantity) { if (ModelState.IsValid) { _context.Add(productsQuantity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProdId"] = new SelectList(_context.Product, "Id", "Id", productsQuantity.ProdId); ViewData["ColorId"] = new SelectList(_context.ProductColor, "Id", "Id", productsQuantity.ColorId); ViewData["SizeId"] = new SelectList(_context.ProductSize, "Id", "Id", productsQuantity.SizeId); return(View(productsQuantity)); }
public async Task <IActionResult> Create(Cart cart) { if (ModelState.IsValid) { _context.Add(cart); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProdId"] = new SelectList(_context.Product, "Id", "Id", cart.ProdId); ViewData["ColorId"] = new SelectList(_context.ProductColor, "Id", "Id", cart.ColorId); ViewData["SizeId"] = new SelectList(_context.ProductSize, "Id", "Id", cart.SizeId); ViewData["UserId"] = new SelectList(_context.User, "Id", "Id", cart.UserId); return(View(cart)); }
public async Task Remove(string orderId) { var order = await GetAsync(orderId); if (order != null) { _context.Order.Remove(order); await _context.SaveChangesAsync(); } }