public async Task <IActionResult> PutCorporte(int id, CorporateDto corporateDto) { if (id != corporateDto.Id) { return(BadRequest()); } var corporate = new Corporate( corporateDto.Id, corporateDto.Name, corporateDto.ImageUrl); context.Entry(corporate).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CorporateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private async Task UpdateAsync(CorporateDto input) { if (input.Id != null) { var corporate = await _corporateRepository.FirstOrDefaultAsync((int)input.Id); ObjectMapper.Map(input, corporate); } }
public async Task CreateOrUpdateCorporate(CorporateDto input) { if (input.Id == null) { await CreateAsync(input); } else { await UpdateAsync(input); } }
public async Task <ActionResult <Corporate> > PostCorporte(CorporateDto corporateDto) { var corporte = new Corporate( corporateDto.Id, corporateDto.Name, corporateDto.ImageUrl); context.Corporates.Add(corporte); await context.SaveChangesAsync(); return(CreatedAtAction("GetCorporte", new { id = corporte.Id }, corporte)); }
private async Task CreateAsync(CorporateDto input) { var corporate = ObjectMapper.Map <Corporate>(input); await _corporateRepository.InsertAsync(corporate); }