コード例 #1
0
        public async Task <ActionResult <ClassTech> > PostClassTeches(ClassTech classTech)
        {
            _context.ClassTeches.Add(classTech);
            await _context.SaveChangesAsync();

            return(Created("", classTech));
        }
コード例 #2
0
        public async Task <IActionResult> PutClassTech(int id, ClassTech classTech)
        {
            if (id != classTech.Id)
            {
                return(BadRequest());
            }

            _context.Entry(classTech).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClassTechExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
        public async Task <ActionResult <IEnumerable <object> > > GetByClass([FromBody] ClassTech cs)
        {
            var roles = await _context
                        .ClassRoles
                        .Where(role => role.ClassId == cs.ClassId)
                        .Select(x => new { x.Id, x.Role.Name })
                        .ToListAsync();

            return(roles);
        }
コード例 #4
0
        public async Task <ActionResult <IEnumerable <object> > > GetClassTechesByClassId([FromBody] ClassTech cs)
        {
            var techs = await _context.ClassTeches
                        .Where(x => x.ClassId == cs.ClassId)
                        .Select(x => new { x.Id, x.Tech.Name })
                        .ToListAsync();

            if (techs == null)
            {
                return(NotFound());
            }

            return(techs);
        }