public async Task <IActionResult> PutInstructorDetail([FromRoute] int id, [FromBody] InstructorDetail instructorDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != instructorDetail.Id) { return(BadRequest()); } _context.Entry(instructorDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InstructorDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void dtgListInstructors_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } InstructorDetail formDetail = new InstructorDetail(dtgListInstructors.Rows[e.RowIndex].Cells["id"].Value.ToString()); formDetail.ShowDialog(); listInstructor(); }
public async Task <IActionResult> PostInstructorDetail([FromBody] InstructorDetail instructorDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.InstructorDetails.Add(instructorDetail); await _context.SaveChangesAsync(); return(CreatedAtAction("GetInstructorDetail", new { id = instructorDetail.Id }, instructorDetail)); }
public InstructorDetail GetInstructorByDetail(int id) { var model = new InstructorDetail(); using (var ctx = new ApplicationDbContext()) { var entity = ctx.Instructors.FirstOrDefault(i => i.InstructorId == id); model.InstructorId = entity.InstructorId; model.FullName = entity.FullName; model.ProgramId = entity.ProgramId; model.ProgramName = entity.ProgramName; model.AcademyId = entity.AcademyId; model.AcademyName = entity.AcademyName; model.Ratings = entity.Ratings; model.CreatedBy = entity.CreatedBy; } return(model); }