Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,username,email,password,fullName,birth,gender,type,closed,created")] Customer customer)
        {
            if (id != customer.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Edit(int id, [Bind("id,account,product,stars,title,content,created")] Comment comment)
        {
            if (id != comment.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentExists(comment.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(comment));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,OrderId,ProductId,Amount")] OrdersDetails ordersDetails)
        {
            if (id != ordersDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ordersDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdersDetailsExists(ordersDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"]   = new SelectList(_context.Orders, "Id", "Id", ordersDetails.OrderId);
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", ordersDetails.ProductId);
            return(View(ordersDetails));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("id,admin,created,content,type")] News news)
        {
            if (id != news.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(news);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NewsExists(news.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(news));
        }
Beispiel #5
0
        public async Task <IActionResult> Edit(int id, [Bind("id,product,cart,order,price,quantity")] Item item)
        {
            if (id != item.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(item.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(item));
        }
Beispiel #6
0
        public async Task <IActionResult> Edit(int id, [Bind("id,customer,created,discard")] ShoppingCart shoppingCart)
        {
            if (id != shoppingCart.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shoppingCart);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShoppingCartExists(shoppingCart.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(shoppingCart));
        }
        public async Task <IActionResult> Edit(int id, [Bind("id,admin,created,due,by,discount,description")] Promotion promotion)
        {
            if (id != promotion.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(promotion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PromotionExists(promotion.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(promotion));
        }
        public async Task <IActionResult> Edit(int id, [Bind("id,name,supplier,summary,description,price,category")] Product product)
        {
            if (id != product.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Edit(int id, [Bind("id,order,paid,payer,method,note")] Payment payment)
        {
            if (id != payment.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(payment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentExists(payment.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(payment));
        }
        public async Task <IActionResult> Edit(int id, [Bind("id,customer,promotion,ordered,address,status,total")] Order order)
        {
            if (id != order.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(order));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,LastName,Address")] Clients clients)
        {
            if (id != clients.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clients);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientsExists(clients.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clients));
        }
Beispiel #12
0
        public async Task <IActionResult> Edit(int id, [Bind("id,customer,detail,phone,isDefaultAddress,isHomeAddress")] Address address)
        {
            if (id != address.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(address);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AddressExists(address.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(address));
        }
Beispiel #13
0
        public async Task <IActionResult> Edit(int id, [Bind("id,product,size,quantity")] ProductSize productSize)
        {
            if (id != productSize.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productSize);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductSizeExists(productSize.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(productSize));
        }
Beispiel #14
0
        public async Task <IActionResult> Edit(int id, [Bind("id,whose,content,format,created")] Image image)
        {
            if (id != image.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(image);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ImageExists(image.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(image));
        }
        private void updateProductList(int id, int sizeId, string func, int sizeAlter = 0, string sortOrder = "#")
        {
            IEnumerable <Product> products = this.db.Product; //

            products = products.Where(s => s.name.Contains(search) ||
                                      s.supplier.Contains(search));              //
            IEnumerable <ProductSize> sizes = this.db.ProductSize;

            sizes = sizes.Where(s => s.product == this.aProducts.choosenProduct.id);
            for (int i = 0; i < pSortParams.Length; i++)
            {
                if (pSortParams[i].Contains(sortOrder))
                {
                    pSortParams[i] = sortOrder + (pSortParams[i].Contains("_asc") ? "_desc" : "_asc");
                    switch (pSortParams[i])
                    {
                    case "cat_desc":
                        products = products.OrderByDescending(p => p.category);
                        break;

                    case "cat_asc":
                        products = products.OrderBy(p => p.category);
                        break;

                    case "sup_desc":
                        products = products.OrderByDescending(p => p.supplier);
                        break;

                    case "sup_asc":
                        products = products.OrderBy(p => p.supplier);
                        break;

                    case "price_desc":
                        products = products.OrderByDescending(p => p.price);
                        break;

                    case "price_asc":
                        products = products.OrderBy(p => p.price);
                        break;

                    case "name_desc":
                        products = products.OrderByDescending(p => p.name);
                        break;

                    case "name_asc":
                        products = products.OrderBy(p => p.name);
                        break;

                    case "size_desc":
                        sizes = sizes.OrderByDescending(p => p.size);
                        break;

                    case "size_asc":
                        sizes = sizes.OrderBy(p => p.size);
                        break;

                    case "quantity_desc":
                        sizes = sizes.OrderByDescending(p => p.quantity);
                        break;

                    case "quantity_asc":
                        sizes = sizes.OrderBy(p => p.quantity);
                        break;
                    }
                }
            }
            this.aProducts.products = products.Skip((pPageInfor.pageIndex - 1) * pPageInfor.pageSize).Take(pPageInfor.pageSize);
            this.aProducts.sizes    = sizes;

            if (func == "details")
            {
                this.aProducts.choosenProduct = db.Product.Where(p => p.id == id).FirstOrDefault();
                this.aProducts.sizes          = db.ProductSize.Where(s => s.product == this.aProducts.choosenProduct.id);
                this.aProducts.editedSize     = new ProductSize();
            }
            if (sizeId != 0 && sizeAlter != 0)
            {
                ProductSize sz = db.ProductSize.FirstOrDefault(s => s.id == sizeId);
                db.Entry(sz).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
                sz.quantity        = Convert.ToString((int.Parse(sz.quantity) + sizeAlter));
                db.Update(sz);
                db.SaveChanges();
            }

            if (func == "edit")
            {
                this.isCreation = false;
                this.aProducts.editedProduct = db.Product.FirstOrDefault(p => p.id == id);
            }
            else if (func == "delete")
            {
                Product pd = db.Product.FirstOrDefault(p => p.id == id);
                db.Product.Remove(pd);
                db.SaveChanges();
            }
            else
            {
                this.isCreation = true;
                this.aProducts.editedProduct = new Product()
                {
                    id = 0
                };
            }
        }