コード例 #1
0
        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());
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }