Пример #1
0
 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));
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
 public void DeletePersonById(int personId)
 {
     _logger.LogInformation($"Deleting person with ID {personId}");
     Context.Person entity = _dbContext.People.Find(personId);
     _dbContext.Remove(entity);
 }