diff --git a/Services/ProfileService.cs b/Services/ProfileService.cs index f49cdb7b93790924e582cd43e9123b073546240a..35390f4fbf8659d681ea4225f2e38a07ad19d6f6 100644 --- a/Services/ProfileService.cs +++ b/Services/ProfileService.cs @@ -4,6 +4,7 @@ using System.Text; using AutoMapper; using Exceptions; using Microsoft.EntityFrameworkCore; +using Models; using Models.DTOs; using Models.Entities; using Repositories; @@ -41,6 +42,12 @@ public class ProfileService : IProfileService throw new ProfileException("Please enter valid age."); var record = _mapper.Map<Profile>(profile); + if (user.ProfileId != null) + { + var existingProfile = await _profileRepository.GetAll().AsNoTracking() + .FirstOrDefaultAsync(p => p.Id == user.ProfileId); + record.Id = existingProfile!.Id; + } if (profile.FavouriteShows != null && profile.FavouriteShows.Count != 0) {