public async Task UpdateItem(PersonTypeDTO personTypeDTO) { var personType = _mapper.Map <PersonType>(personTypeDTO); _dbContext.PersonTypes.Update(personType); await _dbContext.SaveChangesAsync(); }
public async Task <ActionResult> PostPersonType(PersonTypeDTO personTypeDTO) { try { await _service.InsertItem(personTypeDTO); return(CreatedAtAction("GetPersonType", new { id = personTypeDTO.PersonTypeId }, personTypeDTO)); } catch (Exception ex) { Log.LogError($"Chyba při ukládání do databáze: {ex.InnerException}"); return(NotFound()); } }
public async Task <IActionResult> PutPersonType(int id, PersonTypeDTO personTypeDTO) { if (id != personTypeDTO.PersonTypeId) { Log.LogError($"Chyba!!! Záznam s tímto Id nebyl nalezen."); return(BadRequest()); } try { await _service.UpdateItem(personTypeDTO); return(CreatedAtAction("GetPersonType", new { id = personTypeDTO.PersonTypeId }, id)); } catch (Exception ex) { Log.LogError($"Chyba při ukládání do databáze: {ex.InnerException}"); return(NotFound()); } }