public async Task <IActionResult> Edit(int id, [Bind("Id,Person,Department")] Professor professor) { if (id != professor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(professor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfessorExists(professor.Id)) { return(NotFound()); } throw; } return(RedirectToAction("Index")); } ViewData["Department"] = new SelectList(_context.Department, "Id", "Name", professor.Department); ViewData["Person"] = new SelectList(_context.Person, "Id", "Name", professor.Person); return(View(professor)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Subject subject) { if (id != subject.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subject); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubjectExists(subject.Id)) { return(NotFound()); } throw; } return(RedirectToAction("Index")); } return(View(subject)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Person,StudentsGroup")] Student student) { if (id != student.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(student); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.Id)) { return(NotFound()); } throw; } return(RedirectToAction("Index")); } ViewData["Person"] = new SelectList(_context.Person, "Id", "Name", student.Person); ViewData["StudentsGroup"] = new SelectList(_context.Studentsgroup, "Id", "Name", student.StudentsGroup); return(View(student)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,DateStart,DateFinish,Specialty,Course")] StudentsGroup studentsGroup) { if (id != studentsGroup.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(studentsGroup); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentsGroupExists(studentsGroup.Id)) { return(NotFound()); } throw; } return(RedirectToAction("Index")); } ViewData["Specialty"] = new SelectList(_context.Specialty, "Id", "Name", studentsGroup.Specialty); return(View(studentsGroup)); }
public async Task <int> Update(T entity) { using (var db = new PostgresContext()) { db.Set <T>(); db.Update(entity); return(await db.SaveChangesAsync()); } }
public async Task <IActionResult> Update([ModelBinder(BinderType = typeof(PersonSettingsBinder))] Person updPerson) { if (UserId() != updPerson.Id) { return(NotFound()); } if (ModelState.IsValid) { _context.Update(updPerson); await _context.SaveChangesAsync(); return(RedirectToAction("Details", new { id = UserId() })); } return(RedirectToAction("Setting", new { id = UserId() })); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Student,Curriculum,Date")] Sheet sheet) { if (id != sheet.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sheet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SheetExists(sheet.Id)) { return(NotFound()); } throw; } return(RedirectToAction("Index")); } ViewData["Curriculum"] = new SelectList( from cur in _context.Curriculum select new { cur.Id, Name = $"{cur.SpecialtyNavigation.Name}, {cur.SubjectNavigation.Name}, Course: {cur.Course}, Semester: {cur.Semester}" }, "Id", "Name", sheet.Curriculum); ViewData["Student"] = new SelectList(from student in _context.Student select new { student.Id, Name = $"{student.PersonNavigation.Surname} {student.PersonNavigation.Name} {student.PersonNavigation.Middlename}" }, "Id", "Name", sheet.Student); return(View(sheet)); }
public void Update(Error error) { var originalError = _context.Errors .AsNoTracking() .Where(e => e.Id == error.Id) .FirstOrDefault(); _context.Update(new DalError { Id = error.Id, CreationDate = originalError.CreationDate, BriefDescription = originalError.BriefDescription, FullDescription = originalError.FullDescription, Status = error.Status, Priority = originalError.Priority, Seriousness = originalError.Seriousness, DalUserId = originalError.DalUserId }); _context.SaveChanges(true); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Subject,Semester,Course,Specialty,HoursAmount,ProfessorId,HasExam")] Curriculum curriculum) { if (id != curriculum.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(curriculum); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CurriculumExists(curriculum.Id)) { return(NotFound()); } throw; } return(RedirectToAction("Index")); } ViewData["ProfessorId"] = new SelectList(_context.Professor.Select(professor => new { professor.Id, Name = (from person in _context.Person where person.Id == professor.Person select $"{person.Surname} {person.Name} {person.Middlename}").Single() }), "Id", "Name", curriculum.ProfessorId); ViewData["Specialty"] = new SelectList(_context.Specialty, "Id", "Name", curriculum.Specialty); ViewData["Subject"] = new SelectList(_context.Subject, "Id", "Name", curriculum.Subject); return(View(curriculum)); }