Пример #1
0
        public async Task <ActionResult> UpdatePersonBybussinessId(Guid rowGuid, [FromBody] PersonNameBaseDto personName, CancellationToken cancellation)
        {
            var response = await _adventureWorksService.PatchPersonsNameAsync(rowGuid, personName, cancellation);

            if (response == null)
            {
                return(NotFound($"Couldn't find the person for the given rowGuid {rowGuid}"));
            }
            return(Ok(response.Map()));
        }
        public async Task <PersonNameDto> PatchPersonsNameAsync(Guid rowGuid, PersonNameBaseDto personNameDto,
                                                                CancellationToken cancellation)
        {
            var person = (await _repo.Person.Where(c => c.Rowguid == rowGuid).ToListAsync(cancellation)).FirstOrDefault();

            if (person == null)
            {
                return(null);
            }
            person.FirstName    = personNameDto.FirstName;
            person.MiddleName   = personNameDto.MiddleName;
            person.LastName     = personNameDto.LastName;
            person.ModifiedDate = DateTime.UtcNow;
            await _repo.SaveChangesAsync(cancellation);

            return(_mapper.Map <PersonNameDto>(person));
        }