diff --git a/Group17profile.csproj b/Group17profile.csproj index 05a473c05d03e6c688f4fd24031d6f6d34dfdcd2..1c2942e4b35183308fbbc688d166e5f39616205e 100644 --- a/Group17profile.csproj +++ b/Group17profile.csproj @@ -11,16 +11,16 @@ <PackageReference Include="AutoMapper" Version="12.0.1" /> <PackageReference Include="Azure.Storage.Blobs" Version="12.16.0-beta.1" /> <PackageReference Include="Azure.Storage.Common" Version="12.15.0-beta.1" /> - <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.0-preview.2.23153.2" /> + <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="7.0.5" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" /> <PackageReference Include="Microsoft.Azure.Cosmos" Version="3.32.3" /> - <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-preview.2.23128.3" /> - <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0-preview.2.23128.3"> + <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0-preview.2.23128.3" /> - <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0-preview.2.23128.3"> + <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> diff --git a/Services/ProfileService.cs b/Services/ProfileService.cs index 04b676604546887a8c2b724d672ac91fb266698b..f49cdb7b93790924e582cd43e9123b073546240a 100644 --- a/Services/ProfileService.cs +++ b/Services/ProfileService.cs @@ -40,13 +40,12 @@ public class ProfileService : IProfileService if (age is <= 16 or >= 100) throw new ProfileException("Please enter valid age."); - var newDetails = _mapper.Map<Profile>(profile); var record = _mapper.Map<Profile>(profile); - if (!string.IsNullOrWhiteSpace(newDetails.FavouriteShows)) + if (profile.FavouriteShows != null && profile.FavouriteShows.Count != 0) { var builder = new StringBuilder(); - foreach (var show in newDetails.FavouriteShows) + foreach (var show in profile.FavouriteShows) builder.Append($"{show},"); record.FavouriteShows = builder.ToString(); @@ -55,6 +54,8 @@ public class ProfileService : IProfileService if (user.ProfileId == null) { var newProfile = await _profileRepository.CreateAndSaveAsync(record); + user.ProfileId = newProfile.Id; + await _userRepository.UpdateAndSaveAsync(user); return _mapper.Map<ProfileDTO>(newProfile); } @@ -96,6 +97,8 @@ public class ProfileService : IProfileService BannerUrl = image.ToString() }; await _profileRepository.CreateAndSaveAsync(newProfile); + user.ProfileId = newProfile.Id; + await _userRepository.UpdateAndSaveAsync(user); return _storageService.GetSasForFile(Constants.AzureBlobContainer.BannerPictures, image.ToString()); }