//עדכון כמות המלאי בעת שהלקוח מוסיפה אחת מהאופציות שבמלאי לכמויות שלו
        // GET: ConnectTables/Details/quantities
        public async Task <IActionResult> Details(Quantities quantities)
        {
            if (quantities.ProductesId == 0)
            {
                return(NotFound());
            }

            var connectTable = await _context.ConnectTable
                               .Include(c => c.Color)
                               .Include(c => c.Productes)
                               .Include(c => c.Size)
                               .SingleOrDefaultAsync(m => m.ProductesId == quantities.ProductesId && m.ColorId == quantities.ColorId && m.SizeId == quantities.SizeId);

            if (connectTable.AmountInStock < quantities.AmountOfOrders)
            {
                quantities.AmountOfOrders = 0;
                _context.Update(quantities);
                await _context.SaveChangesAsync();
            }
            else
            {
                connectTable.AmountInStock = connectTable.AmountInStock - quantities.AmountOfOrders;
                _context.Update(connectTable);
                await _context.SaveChangesAsync();
            }

            if (connectTable == null)
            {
                return(NotFound());
            }

            return(RedirectToAction("Index", "Quantities"));
        }
        public async Task <IActionResult> Add([Bind("ProductesId,SizeId,ColorId,MartId,AmountOfOrders")] Quantities quantities)
        {
            if (quantities.MartId != 0)
            {
                _context.Add(quantities);
                await _context.SaveChangesAsync();

                if (!ConnectTableExist(quantities.ProductesId, quantities.SizeId, quantities.ColorId))
                {
                    //כאשר אופציה זו לא נמצאת במלאי(בטבלה המקשרת
                    quantities.AmountOfOrders = 0;
                    _context.Update(quantities);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }

                if (ConnectTableExist(quantities.ProductesId, quantities.SizeId, quantities.ColorId))
                {
                    return(RedirectToAction("Details", "ConnectTables", quantities));
                }
            }

            return(RedirectToAction("LogIn", "Customers"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductName,Color,Size,Price,AmountInStock,AmountOfOrders,DeliveryPrice,ImgId")] Productes productes)
        {
            if (id != productes.ProductId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductesExists(productes.ProductId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(productes));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("MartId,CustomerId")] Mart mart)
        {
            if (id != mart.MartId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mart);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MartExists(mart.MartId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mart));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Categories categories)
        {
            if (id != categories.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categories);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoriesExists(categories.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("List"));
            }
            return(View(categories));
        }
示例#6
0
        public async Task <IActionResult> Edit(int id, [Bind("SubCategoryId,SubName")] SubCategory subCategory)
        {
            if (id != subCategory.SubCategoryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubCategoryExists(subCategory.SubCategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(subCategory));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id")] Mart mart)
        {
            if (id != mart.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mart);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MartExists(mart.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["Id"] = new SelectList(_context.Customer, "Id", "Id", mart.Id);
            return(View(mart));
        }
示例#8
0
        public async Task <IActionResult> Edit(int id, [Bind("SubCategoryId,SubName,CategoryId")] SubCategory subCategory)
        {
            if (id != subCategory.SubCategoryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubCategoryExists(subCategory.SubCategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "CategoryId", subCategory.CategoryId);
            return(View(subCategory));
        }
        public async Task <IActionResult> Edit(int id, [Bind("DetailesId,ProductId,SizeId,ColorId,MartId")] ConectTable conectTable)
        {
            if (id != conectTable.DetailesId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(conectTable);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConectTableExists(conectTable.DetailesId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ColorId"]   = new SelectList(_context.Color, "ColorId", "ColorId", conectTable.ColorId);
            ViewData["MartId"]    = new SelectList(_context.Mart, "MartId", "MartId", conectTable.MartId);
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "ProductId", conectTable.ProductId);
            ViewData["SizeId"]    = new SelectList(_context.Set <Size>(), "SizeId", "SizeId", conectTable.SizeId);
            return(View(conectTable));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductName,Price,AmountInStock,AmountOfOrders,DeliveryPrice,SubCategoryId,ImgId")] Product product)
        {
            if (id != product.ProductId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.ProductId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubCategoryId"] = new SelectList(_context.SubCategory, "SubCategoryId", "SubCategoryId", product.SubCategoryId);
            return(View(product));
        }
示例#11
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,FirstName,LastName,PhoneNumber,Address,City,CreditCard,Mail,Password")] Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(customer));
        }
示例#12
0
        public async Task <IActionResult> Edit(int id, [Bind("SizeId,SizeName")] Size size)
        {
            if (id != size.SizeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(size);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SizeExists(size.SizeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(size));
        }
示例#13
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ProductName,Price,AmountInStock,AmountOfOrders,DeliveryPrice,ImgId,SubCategoryId")] Productes productes)
        {
            if (id != productes.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductesExists(productes.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("List"));
            }
            ViewData["SubIdE"] = new SelectList(await _context.SubCategory.ToListAsync(), "Id", "Name", productes.SubCategory.SubName);
            return(View(productes));
        }
示例#14
0
        public async Task <IActionResult> Edit(int id, [Bind("ColorId,ColorName")] Color color)
        {
            if (id != color.ColorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(color);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ColorExists(color.ColorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(color));
        }