public async Task <ActionResult <Costumer> > CreateCostumer(CostumerDTO costumerDTO) { try { _context.Costumers.Add(_mapper.Map <Costumer>(costumerDTO)); await _context.SaveChangesAsync(); //El NoContent() regresa el 204 return(Ok()); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public async Task <IActionResult> UpdateCostumer(int id, CostumerDTO costumerDTO) { try { var costumers = await _context.Costumers .FirstOrDefaultAsync(c => c.Status && c.Id == id); if (costumers is null) { return(NotFound()); } _mapper.Map(costumerDTO, costumers); await _context.SaveChangesAsync(); return(Ok()); } catch (Exception ex) { return(StatusCode(500, ex)); } }