Exemple #1
0
        public async Task <IActionResult> Edit(string id, [Bind("Name,Email,Password,ConfirmPassword,Address,Phone")] RegisterModel registerModel)
        {
            if (id != registerModel.Name)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(registerModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RegisterModelExists(registerModel.Name))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(registerModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,ProductName,ImgUrl,Price,Description")] LaptopModel laptopModel)
        {
            if (id != laptopModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(laptopModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LaptopModelExists(laptopModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(laptopModel));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(string id, [Bind("Name,RollNo,Class,Sec,EnglishM,MathsM,ScienceM,ID")] LqStudentModel lqStudentModel)
        {
            if (id != lqStudentModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lqStudentModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LqStudentModelExists(lqStudentModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(lqStudentModel));
        }
 public async Task<EmployeeModel> Edit(string id, EmployeeModel employeeModel)
 {
     
         try
         {
             _context.Update(employeeModel);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!EmployeeModelExists(employeeModel.ID))
             {
                 return null;
             }
             else
             {
                 throw;
             }
         }
         
     
     return employeeModel;
 }