public async Task <IActionResult> Put(int id, [FromBody] TypeComptesViewModel typeComptes) { if (ModelState.IsValid) { try { TypeComptes _typeComptes = Mapper.Map <TypeComptes>(typeComptes); //_typeComptes.Name = _typeComptes.Name.ToUpper(); _unitOfWork.TypeComptes.Update(_typeComptes); await _unitOfWork.SaveChangesAsync(); return(Ok("OK")); } catch (Exception ex) { return(BadRequest(ex.Data)); } } else { return(BadRequest(ModelState)); } }
public async Task <IActionResult> Post([FromBody] TypeComptesViewModel typeComptes) { if (ModelState.IsValid) { try { TypeComptes _typeComptes = Mapper.Map <TypeComptes>(typeComptes); //_typeComptes.Name = _typeComptes. ; await _unitOfWork.TypeComptes.AddAsync(_typeComptes); return(Ok(await _unitOfWork.SaveChangesAsync())); } catch (Exception ex) { return(BadRequest(ex.Data)); } } return(BadRequest()); }