コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,Name,Address,CheckIn,CheckOut,RoomNumber,EmailAddress,Billing")] CustomerModel customerModel)
        {
            if (id != customerModel.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerModelExists(customerModel.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customerModel));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Idnumber,Name,Course,Year,TshirtColor,Size,AmountPaid")] StudentModel studentModel)
        {
            if (id != studentModel.ID)
            {
                return(NotFound());
            }

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