예제 #1
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Email,Password")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("wItemId,Name,Description,Manufacturer,Price,Quantity")] wItems wItems)
        {
            if (id != wItems.wItemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(wItems);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!wItemsExists(wItems.wItemId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(wItems));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductTypeId,TypeName,Description,Features")] ProductType productType)
        {
            if (id != productType.ProductTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductTypeExists(productType.ProductTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(productType));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,StorageConditions,Packaging,ExpiryDate,Price,ProductTypeId,ManufacturerId")] Product product)
        {
            if (!User.IsInRole(Areas.Identity.Roles.Admin))
            {
                return(RedirectToAction("Index", "Products"));
            }
            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)));
            }
            ViewData["ManufacturerId"] = new SelectList(_context.Manufacturers, "Id", "Name", product.ManufacturerId);
            ViewData["ProductTypeId"]  = new SelectList(_context.ProductTypes, "Id", "Name", product.ProductTypeId);
            return(View(product));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductTypeId,ProductName,Storage,Packaging,ExpirationDate")] 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["ProductTypeId"] = new SelectList(_context.ProductTypes, "ProductTypeId", "ProductTypeId", product.ProductTypeId);
            return(View(product));
        }
예제 #6
0
        public async Task <IActionResult> Edit(long id, [Bind("ClientId,Id,Name,WarehouseSector,PlacingDate")] Stock stock)
        {
            if (id != stock.Id)
            {
                _logger.LogError("Stock id not found.");
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stock);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StockExists(stock.Id))
                    {
                        _logger.LogError("Stock does not exist.");
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }
            ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "FirstName", stock.ClientId);
            return(View(stock));
        }
예제 #7
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,FirstName,LastName,DateOfBirth,PhoneNumber,Type")] Client client)
        {
            if (id != client.Id)
            {
                _logger.LogError("Client id not found.");
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.Id))
                    {
                        _logger.LogError("Client not found.");
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }
            return(View(client));
        }
예제 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Address,Phone")] Supplier supplier)
        {
            if (!User.IsInRole(Areas.Identity.Roles.Admin))
            {
                return(RedirectToAction("Index", "Suppliers"));
            }
            if (id != supplier.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplier);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupplierExists(supplier.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Employee employee)
        {
            if (!User.IsInRole(Areas.Identity.Roles.Admin))
            {
                return(RedirectToAction("Index", "Employees"));
            }
            if (id != employee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
        public async Task <IActionResult> Edit(int id, [Bind("StorageId,ReceiptDate,Volume,Cost,Employee,ProductId,DialerId")] Storage storage)
        {
            if (id != storage.StorageId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(storage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StorageExists(storage.StorageId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DialerId"]  = new SelectList(_context.Dialers, "DialerId", "DialerId", storage.DialerId);
            ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductId", storage.ProductId);
            return(View(storage));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,CustomerName,CustomerAddress,TelNumber")] 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(nameof(Index)));
            }
            return(View(customer));
        }
예제 #12
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderId,OrderDate,DispatchDate,Delivery,Volume,Cost,Employee,ProductId,CustomerId")] Order order)
        {
            if (id != order.OrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.OrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId", order.CustomerId);
            ViewData["ProductId"]  = new SelectList(_context.Products, "ProductId", "ProductId", order.ProductId);
            return(View(order));
        }
예제 #13
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Code,TarihG,TarihK,Gumruk")] Warehouse warehouse)
        {
            if (id != warehouse.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(warehouse);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WarehouseExists(warehouse.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(warehouse));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,OrderDate,DepartureDate,Quantity,Price,CustomerId,ProductId,DeliveryMethodId,EmployeeId")] CustomerProduct customerProduct)
        {
            if (!User.IsInRole(Areas.Identity.Roles.Admin))
            {
                return(RedirectToAction("Index", "CustomerProducts"));
            }
            if (id != customerProduct.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerProduct);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerProductExists(customerProduct.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"]       = new SelectList(_context.Customers, "Id", "Name", customerProduct.CustomerId);
            ViewData["DeliveryMethodId"] = new SelectList(_context.DeliveryMethods, "Id", "Name", customerProduct.DeliveryMethodId);
            ViewData["EmployeeId"]       = new SelectList(_context.Employees, "Id", "Name", customerProduct.EmployeeId);
            ViewData["ProductId"]        = new SelectList(_context.Products, "Id", "Name", customerProduct.ProductId);
            return(View(customerProduct));
        }
        public async Task <IActionResult> Edit(int id, Products product)
        {
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);

                    _context.Entry(product.Category).State = EntityState.Unchanged;

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductsExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            var allCategories = this._context.Category.ToList();

            this.ViewBag.Categories = allCategories;

            return(View(product));
        }
예제 #16
0
 public void Update(T entity)
 {
     warehouseContext.Update(entity);
     warehouseContext.SaveChanges();
 }