Beispiel #1
0
        public async Task <ClientProfileDto> UpdateClientProfileAsync(UpdateClientProfileDto dto)
        {
            var clientProfile = await _context.ClientProfiles.FindAsync(dto.Id);

            if (clientProfile == null)
            {
                throw new NotFoundException(nameof(ClientProfile), dto.Id);
            }

            clientProfile = mapper.Map(dto, clientProfile);

            _context.Update(clientProfile);

            await _context.SaveChangesAsync();

            return(mapper.Map <ClientProfileDto>(clientProfile));
        }
        public async Task <ActionResult <ClientProfileDto> > UpdateClientProfile(Guid id, UpdateClientProfileDto dto)
        {
            if (id != dto.Id)
            {
                return(BadRequest());
            }
            try
            {
                var dto2 = await clientManager.UpdateClientProfileAsync(dto);

                return(Ok(dto2));
            }
            catch (NotFoundException exc)
            {
                return(Problem(exc.Message, statusCode: StatusCodes.Status404NotFound));
            }
        }