public async Task UpdateItem(PersonTypeDTO personTypeDTO)
        {
            var personType = _mapper.Map <PersonType>(personTypeDTO);

            _dbContext.PersonTypes.Update(personType);

            await _dbContext.SaveChangesAsync();
        }
Esempio n. 2
0
        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());
            }
        }
Esempio n. 3
0
        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());
            }
        }