public async Task<IActionResult> PutSiret([FromRoute] int id, [FromBody] Siret siret) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != siret.Id) { return BadRequest(); } _context.Entry(siret).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SiretExists(id)) { return NotFound(); } else { throw; } } return NoContent(); }
public void SetRegistrationKind(RegistrationKind kind, string city, string code) { if (kind == RegistrationKind.RCS) { Identifier = $"{kind:G} {city.Trim()} {Siret.Substring(0, 9)} "; } if (kind == RegistrationKind.RM) { Identifier = $"{kind:G} {Siret.Substring(0, 9)} {code.Trim()}"; } }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value == null) { return(null); } if (Siret.Check(value.ToString())) { return(null); } else { return(new ValidationResult("Le numéro de SIRET n'est pas valide.")); } }
public async Task<IActionResult> PostSiret([FromBody] SiretForInsertDto siretDto) { if (!ModelState.IsValid) { return BadRequest(ModelState); } // Check si le Siren existe, sinon, 404 var sirenId = siretDto.SirenId; if(await _context.Sirens.FindAsync(sirenId) == null) { return NotFound("Siren inexistant"); } Siret siret = _mapper.Map<Siret>(siretDto); _context.Sirets.Add(siret); await _context.SaveChangesAsync(); return CreatedAtAction("GetSiret", new { id = siret.Id }, siret); }
public void insertSiret(Siret siret) { throw new NotImplementedException(); }