public async Task UpdateAsync(SuperheroDTO model) { logger.LogTrace($"{nameof(UpdateAsync)} {model}", model); var entity = this.mapper.Map <Superhero>(model); await this.superheroRepository.UpdateAsync(entity); }
public async Task <SuperheroDTO> CreateAsync(SuperheroDTO model) { logger.LogTrace($"{nameof(CreateAsync)} {model}", model); var entity = this.mapper.Map <Superhero>(model); var result = await this.superheroRepository.AddAsync(entity); return(this.mapper.Map <SuperheroDTO>(result)); }
public async Task <IActionResult> PostAsync([FromBody] SuperheroDTO superheroDTO) { if (superheroDTO == null) { return(BadRequest(new ArgumentNullException())); } var dto = await this.superheroService.CreateAsync(superheroDTO); return(CreatedAtAction(nameof(GetByIdAsync), new { id = dto.Id }, new Response <SuperheroDTO>(dto))); }
public async Task <IActionResult> GetByIdAsync(int id) { SuperheroDTO dto = await this.superheroService.SingleByIdAsync(id); if (dto == null) { return(NotFound()); } return(Ok(new Response <SuperheroDTO>(dto))); }
public async Task <IActionResult> PutAsync(int id, [FromBody] SuperheroDTO superheroDTO) { if (id != superheroDTO.Id) { return(BadRequest()); } if (!await this.superheroService.ExistsAsync(id)) { return(NotFound()); } await this.superheroService.UpdateAsync(superheroDTO); return(NoContent()); }
public void Put([FromBody] SuperheroDTO value) => _kosmonautService.Update(value);
public void Post([FromBody] SuperheroDTO value) => _kosmonautService.Create(value);