Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,InvoiceDate,Address,EmployeeId,UserId,Total")] Invoice invoice)
        {
            if (id != invoice.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(invoice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InvoiceExists(invoice.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(invoice));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("UserId,Email,Password,FullName,Gender,Dob,Phonenumber,Address,Image")] StoreUser storeUser)
        {
            if (id != storeUser.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(storeUser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StoreUserExists(storeUser.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(storeUser));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,CategoryId,ProductCategory,ProductName,Image,Description,SalePrice,TimesBooked,Quantity")] 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)));
            }
            return(View(product));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id_Invoice,ProductId,Quantity")] InvoiceDetail invoiceDetail)
        {
            if (id != invoiceDetail.Id_Invoice)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(invoiceDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InvoiceDetailExists(invoiceDetail.Id_Invoice))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(invoiceDetail));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProductCategory_ID,PD_Name,PD_Description")] ProductCategory productCategory)
        {
            if (id != productCategory.ProductCategory_ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductCategoryExists(productCategory.ProductCategory_ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(productCategory));
        }
Пример #6
0
        public async Task <IActionResult> AddOrEditEmployee([Bind("EmployeeId,EmpCode,Position,OfficeLocation,HireDate,BaseSalary")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                if (employee.EmployeeId == 0)
                {
                    _context.Add(employee);
                }
                else
                {
                    _context.Update(employee);
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }