public async Task <bool> UpdateEntityByIdAsync(UserUpdateRequest request, string id) { var entity = _mapper.Map <UserUpdateRequest, User>(request); entity.Id = id; var existingEntity = await GetEntityByIdAsync(id); if (string.IsNullOrWhiteSpace(existingEntity.PhotoURL)) { entity.PhotoURL = existingEntity.PhotoURL; } else if (!existingEntity.PhotoURL.Equals(entity.PhotoURL)) { if (await _fileStorageProvider.IsExist(existingEntity.PhotoURL)) { await _fileStorageProvider.DeleteFileAsync(existingEntity.PhotoURL); } entity.PhotoURL = await _fileStorageProvider.UploadFileBase64Async(entity.PhotoURL, request.PhotoType); // TODO: change here for real image type } // In returns updated entity, you could do smth with it or just leave as it is var updated = await _uow.UsersRepository.UpdateAsync(entity); var result = await _uow.SaveAsync(); return(result); }