diff options
| author | transtrike <transtrike@gmail.com> | 2021-03-26 22:05:07 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-03-26 22:05:07 +0200 |
| commit | 416fd94399bf0b58fc0d201c0294f0869517a743 (patch) | |
| tree | e99a3ec893cf7437963c4124744f1707747e7426 | |
| parent | 9b04b4f2b031a3c631dba65908f277996015ae05 (diff) | |
| download | DevHive-416fd94399bf0b58fc0d201c0294f0869517a743.tar DevHive-416fd94399bf0b58fc0d201c0294f0869517a743.tar.gz DevHive-416fd94399bf0b58fc0d201c0294f0869517a743.zip | |
Rating's GetById and GetRatingByPostAndUser return null if User hasn't rated; Updated connection string
| -rw-r--r-- | src/Services/DevHive.Services/Services/RatingService.cs | 10 | ||||
| -rw-r--r-- | src/Web/DevHive.Web/appsettings.json | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/Services/DevHive.Services/Services/RatingService.cs b/src/Services/DevHive.Services/Services/RatingService.cs index 1f77a6e..9d8f4b0 100644 --- a/src/Services/DevHive.Services/Services/RatingService.cs +++ b/src/Services/DevHive.Services/Services/RatingService.cs @@ -57,8 +57,9 @@ namespace DevHive.Services.Services #region Read public async Task<ReadRatingServiceModel> GetRatingById(Guid ratingId) { - Rating rating = await this._ratingRepository.GetByIdAsync(ratingId) ?? - throw new ArgumentException("The rating does not exist"); + Rating rating = await this._ratingRepository.GetByIdAsync(ratingId); + if (rating is null) + return null; ReadRatingServiceModel readRatingServiceModel = this._mapper.Map<ReadRatingServiceModel>(rating); readRatingServiceModel.UserId = rating.User.Id; @@ -68,8 +69,9 @@ namespace DevHive.Services.Services public async Task<ReadRatingServiceModel> GetRatingByPostAndUser(Guid userId, Guid postId) { - Rating rating = await this._ratingRepository.GetRatingByUserAndPostId(userId, postId) ?? - throw new ArgumentException("The rating does not exist"); + Rating rating = await this._ratingRepository.GetRatingByUserAndPostId(userId, postId); + if (rating is null) + return null; ReadRatingServiceModel readRatingServiceModel = this._mapper.Map<ReadRatingServiceModel>(rating); readRatingServiceModel.UserId = rating.User.Id; diff --git a/src/Web/DevHive.Web/appsettings.json b/src/Web/DevHive.Web/appsettings.json index fcf9805..053007d 100644 --- a/src/Web/DevHive.Web/appsettings.json +++ b/src/Web/DevHive.Web/appsettings.json @@ -5,7 +5,7 @@ "audience": "" }, "ConnectionStrings": { - "DEV": "Server=localhost;Port=5432;Database=API;User Id=postgres;Password=;" + "DEV": "Server=localhost;Port=5432;Database=DevHive API;User Id=postgres;Password=;" }, "Cloud": { "cloudName": "devhive", |
