public async Task <ActionResult <ClassTech> > PostClassTeches(ClassTech classTech)
        {
            _context.ClassTeches.Add(classTech);
            await _context.SaveChangesAsync();

            return(Created("", classTech));
        }
        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());
        }
Ejemplo n.º 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);
        }
        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);
        }