public Domain.Model.Person GetPersonById(int personId) { _logger.LogInformation($"Retrieving person id: {personId}"); Context.Person returnPerson = _dbContext.People .First(p => p.PersonId == personId); return(Mapper.MapPerson(returnPerson)); }
public void UpdatePerson(Domain.Model.Person inputPerson) { _logger.LogInformation($"Updating person with ID {inputPerson.Id}"); Context.Person currentEntity = _dbContext.People.Find(inputPerson.Id); Context.Person newEntity = Mapper.UnMapPerson(inputPerson); _dbContext.Entry(currentEntity).CurrentValues.SetValues(newEntity); }
public void AddPerson(Domain.Model.Person inputPerson) { if (inputPerson.Id != 0) { _logger.LogWarning($"Person to be added has an ID ({inputPerson.Id}) already: ignoring."); } _logger.LogInformation("Adding person"); Context.Person entity = Mapper.UnMapPerson(inputPerson); entity.PersonId = 0; _dbContext.Add(entity); }
public void DeletePersonById(int personId) { _logger.LogInformation($"Deleting person with ID {personId}"); Context.Person entity = _dbContext.People.Find(personId); _dbContext.Remove(entity); }