Example #1
0
        public async Task <IActionResult> PostParticipantFormation([FromBody] ParticipantFormation participantFormation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ParticipantFormation.Add(participantFormation);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ParticipantFormationExists(participantFormation.BesoinFormationId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetParticipantFormation", new { id = participantFormation.BesoinFormationId }, participantFormation));
        }
        public async Task <IActionResult> PostParticipantFormation([FromBody] ParticipantFormation participantFormation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ParticipantFormation.Add(participantFormation);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetParticipantFormation", new { id = participantFormation.Id }, participantFormation));
        }
        public async Task <IActionResult> PutParticipantFormation([FromRoute] string id, [FromBody] ParticipantFormation participantFormation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }