Exemplo n.º 1
0
        public async Task <IActionResult> PutSubjects([FromRoute] int id, [FromBody] SubjectsDTO subject)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != subject.Id)
            {
                return(BadRequest());
            }

            _context.Entry(Mapper.Map <Subjects>(subject)).State = EntityState.Modified;

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

            return(NoContent());
        }
        public async Task <IActionResult> PutClassRoom([FromRoute] int id, [FromBody] ClassRoomDTO classRoom)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != classRoom.Id)
            {
                return(BadRequest());
            }

            _context.Entry(Mapper.Map <ClassRoom>(classRoom)).State = EntityState.Modified;

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

            return(NoContent());
        }