public async Task <IActionResult> Edit(int id, [Bind("Id,Startdate,Enddate,Reference,Invoice,Department,Costcenter,Account,ProjectCode,Description,Contractor,LaborPrice,MaterialPrice,StateProject,Userid,Comment,State,CreatedAt,UpdatedAt,Idteam")] Ots ots) { if (id != ots.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ots); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { foreach (var entry in ex.Entries) { if (entry.Entity is Ots) { var proposedValues = entry.CurrentValues; var databaseValues = entry.GetDatabaseValues(); foreach (var property in proposedValues.Properties) { var proposedValue = proposedValues[property]; var databaseValue = databaseValues[property]; // TODO: decide which value should be written to database proposedValues[property] = proposedValue; } // Refresh original values to bypass next concurrency check entry.OriginalValues.SetValues(databaseValues); _context.Update(ots); await _context.SaveChangesAsync(); } else { throw new NotSupportedException( "Don't know how to handle concurrency conflicts for " + entry.Metadata.Name); } } } return(RedirectToAction(nameof(Index))); } return(View(ots)); }
public async Task <IActionResult> Edit(int id, Enrollments enrollments) { if (id != enrollments.IdEnrollment) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enrollments); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollmentsExists(enrollments.IdEnrollment)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(enrollments)); }
public async Task <IActionResult> Edit(int id, Qualification qualification) { if (id != qualification.IdQualification) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(qualification); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QualificationExists(qualification.IdQualification)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdCourseNote"] = new SelectList(_context.Enrollments, "IdEnrollment", "IdEnrollment", qualification.IdCourseNote); ViewData["IdStudentNote"] = new SelectList(_context.Enrollments, "IdEnrollment", "IdEnrollment", qualification.IdStudentNote); return(View(qualification)); }
public async Task <IActionResult> Edit(int id, Courses courses) { if (id != courses.IdCourse) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(courses); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CoursesExists(courses.IdCourse)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(courses)); }