예제 #1
0
        public async Task <PersonDTO> PartialUpdatePerson(int personId, JsonPatchDocument <PersonDTO> patchDoc)
        {
            var person = await _personRepo.GetPersonById(personId);

            if (person == null)
            {
                return(null);
            }

            PersonDTO updatedPerson = PersonMapper.ConvertEntityToModel(person);

            patchDoc.ApplyTo(updatedPerson);

            person = PersonMapper.UpdateEntityFromModel(person, updatedPerson);

            if (person != null && await _personRepo.UpdatePerson(person))
            {
                return(PersonMapper.ConvertEntityToModel(person));
            }

            return(null);
        }
예제 #2
0
        public async Task <PersonDTO> UpdatePerson(int personId, PersonDTO personModel)
        {
            var person = await _personRepo.GetPersonById(personId);

            //upsert
            if (person == null)
            {
                person = new Person()
                {
                    Id = personId
                };
            }

            person = PersonMapper.UpdateEntityFromModel(person, personModel);

            if (person != null && await _personRepo.UpdatePerson(person))
            {
                return(PersonMapper.ConvertEntityToModel(person));
            }

            return(null);
        }