コード例 #1
0
 public async Task <IActionResult> EditProfile(int id, [Bind("Id,Email,Password,Name,Semester,Branch,Role")] User model)
 {
     if (id != model.Id)
     {
         return(View("NotFound"));
     }
     if (ModelState.IsValid)
     {
         try
         {
             context.Update(model);
             await context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!UserExists(model.Id))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction("ViewProfile", "Profile"));
     }
     return(View(model));
 }
コード例 #2
0
 public async Task <IActionResult> Edit(Course course)
 {
     try {
         context.Update(course);
         await context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         ViewBag.ErrorMessage = "Please try again.";
         return(View("NotFound"));
     }
     return(RedirectToAction("ListCourses", "Course"));
 }